Reputation: 5830
I made a library project, and then built it, took the .aar and unzipped it. Took the classes.jar file, which contains the library, and added it inside another project. The project recognises my file, and I can call methods and functions from it. My issue is that I try to call an intent to an Activity from my library, like this:
textView = (TextView) findViewById(R.id.text);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, InCallActivity.class);
intent.putExtra("duration",20);
intent.putExtra("message","test");
intent.putExtra("url","https://facetalk.vidyo-nl.com/mobile.html?roomdirect.html&key=QMvMp3eKTqOeLAWQ6HOvHqFJd0");
intent.putExtra("test","true");
startActivity(intent);
}
});
But I get an issue like this:
08-10 15:02:41.730: E/AndroidRuntime(18572): Process: com.vidyo.facetalklibtest, PID: 18572
08-10 15:02:41.730: E/AndroidRuntime(18572): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.vidyo.facetalklibtest/com.vidyo.vidyocore.activities.InCallActivity}; have you declared this activity in your AndroidManifest.xml?
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1794)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivityForResult(Activity.java:3930)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivityForResult(Activity.java:3890)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivity(Activity.java:4213)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.Activity.startActivity(Activity.java:4181)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.vidyo.facetalklibtest.MainActivity$1.onClick(MainActivity.java:32)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.view.View.performClick(View.java:5204)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.view.View$PerformClick.run(View.java:21153)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Handler.handleCallback(Handler.java:739)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Handler.dispatchMessage(Handler.java:95)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.os.Looper.loop(Looper.java:148)
08-10 15:02:41.730: E/AndroidRuntime(18572): at android.app.ActivityThread.main(ActivityThread.java:5417)
08-10 15:02:41.730: E/AndroidRuntime(18572): at java.lang.reflect.Method.invoke(Native Method)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-10 15:02:41.730: E/AndroidRuntime(18572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-10 15:02:41.731: W/ActivityManager(787): Force finishing activity com.vidyo.facetalklibtest/.MainActivity
Now I found something regarding a manifest-merger manifestmerger.enabled=true
that needs to be set in project.properties file. But I'm working with AndroidStudio, not Eclipse, hence I do not have that file.
How can I fix this issue?
Upvotes: 1
Views: 2615
Reputation: 782
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="com.example.main.mainactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
And in your library just call this to open MainActivity:
Intent intent = new Intent("com.example.main.mainactivity");
startActivity(intent);
Upvotes: 2
Reputation: 782
You need to declare the activity too in the app manifest with the full path:
com.library.domain.activities.yourActivity
And it might work then.
Upvotes: 1
Reputation: 1006549
How can I fix this issue?
Use the library module correctly, adding it as a dependency of the app via either compile project(...)
, compile
pointing to the library's artifact in a repository, or in a pinch a compile file(...)
pointing to the AAR file. Make sure that the AAR has a manifest with the <activity>
element that you seek.
IOW, get rid of the following:
took the .aar and unzipped it. Took the classes.jar file, which contains the library, and added it inside another project.
Manifest merger is automatic with library modules and AARs and Android Studio; there is nothing to specifically enable.
Upvotes: 1