error when run an Android ndk project - android

I clone a android project from github, when i run it on my phone, the android monitor says
10-20 10:47:06.280 6789-6789/com.example.castoryan.orb E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.castoryan.orb, PID: 6789
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-support-annotations-23.2.1_29f2fe0e989481fa50280a028f5e882e46f71793-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-internal_impl-23.2.1_7117fbe4c4e713f034cb1d8c57d472030a47c772-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.2.1_a2ab3f53bcae00d27ab9cfee6bcea6d0e86508d6-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-com.android.support-support-v4-23.2.1_1fa6e3f5d64af6cd0cc82e1ace4c4909c52d1921-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.2.1_f4c2af62f943a2f434d4772015f0efc5b2579810-classes.dex", dex file "/data/data/com.example.castoryan.orb/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.2.1_f3bfe73a3edbcdf71557b98c7782ea66834668ed-classes.dex"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64, /vendor/lib64, /system/lib64]]] couldn't find "libmono.so"
at java.lang.Runtime.loadLibrary(Runtime.java:378)
at java.lang.System.loadLibrary(System.java:998)
at com.example.castoryan.orb.MyNDK.<clinit>(MyNDK.java:19)
at com.example.castoryan.orb.MainActivity.onCreate(MainActivity.java:94)
at android.app.Activity.performCreate(Activity.java:6013)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
at android.app.ActivityThread.access$1200(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5539)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Related

Can't add .so file to Android Studio 3.5.3 using jniLibs

I'm trying to add a .so file to a new Android project. I'm using Android Studio 3.5.3. I've done what was recommended here and here ; so I created folders (jniLibs/arm64-v8a, etc) in src/main and added this to app/build.gradle:
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
I placed the libhl.so file in /app/src/main/jniLibs/arm64-v8a (yes, 64-bit should be ok). The project will compile just fine, but on execution it will show the following error in logcat:
02-17 10:25:31.719 3691-3691/com.example.bmdtest03 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bmdtest03, PID: 3691
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.bmdtest03-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.bmdtest03-2/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libhl.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at com.example.bmdtest03.MainActivity.<clinit>(MainActivity.java:14)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Conclusion: the file is there, the source is updated in build.gradle, what am I missing?
You can manually generate the .so file with NDK . Then you can add the lib.so file in your jni folder.
Add the NDK path to your local.properties.
Refer this page : https://developer.android.com/studio/projects/gradle-external-native-builds
If its not works. You can create javah then you can access it.
Link to make javah : https://developer.android.com/training/articles/perf-jni

How to use jess in Android

I'm trying to use JESS in and Android project. I tried using Jess 6 which is working fine on a web application on netbeans, but it's giving errors. It seems like the version of the jar file is not compatible.
I need help on how to integrate jess with an Android project.
The error is generated from a line of code:
Rete engine = new Rete();
See the error trail below:
2593-2593/com.example.modupe.tryjessapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.modupe.tryjessapp, PID: 2593
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/applet/Applet;
at jess.Rete.getApplet(Unknown Source)
at jess.Batch.batch(Unknown Source)
at jess.Rete.if(Unknown Source)
at jess.Rete.<init>(Unknown Source)
at jess.Rete.<init>(Unknown Source)
at jess.Rete.<init>(Unknown Source)
at com.example.modupe.tryjessapp.MainActivity.<init>(MainActivity.java:17)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.applet.Applet" on path: DexPathList[[zip file "/data/app/com.example.modupe.tryjessapp-1/base.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.modupe.tryjessapp-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.modupe.tryjessapp-1/lib/x86, /system/lib, /vendor/lib]]
....
Jess uses a number of Java APIs that are not supported on Dalvik, Applet being one, but more importantly, java.beans.Introspector. An android-capable version of Jess is available as an alpha build to source licensees only; it hasn't been released.

java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thalmic.android.sample.helloworld, PID: 16803
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.thalmic.android.sample.helloworld/files/instant-run/dex/slice-com.thalmic-myosdk-0.10.0_67ebee2ca6da7cdf5465641b2d9b682feb72b565-classes.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib, /system/lib]]] couldn't find "libgesture-classifier.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at com.thalmic.myo.scanner.Scanner.<clinit>(Scanner.java:31)
at com.thalmic.myo.Hub.init(Hub.java:201)
at com.thalmic.android.sample.helloworld.HelloWorldActivity.onCreate(HelloWorldActivity.java:163)
at android.app.Activity.performCreate(Activity.java:5979)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.access$800(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
Can anyone please help me?
I'm having problem trying to connect Android with Myo by bluetooth.
I think it is an version problem, but I'm kind of lost with this error.

ClassNotFoundException when trying to put Android component into a library

I have two Android projects: an app and a library. The library uses StreamProvider and it is included as an AAR module in the app project. Here are important (changed by me) bits in both projects:
Library project:
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.com.a1ict.mylib">
...
<provider
android:name=".provider.StreamProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
android:resource="#xml/file_paths"/>
</provider>
build.gradle:
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.commonsware.cwac:provider:0.4.3'
}
provider/StreamProvider.java:
package au.com.a1ict.mylib.provider;
public class StreamProvider extends com.commonsware.cwac.provider.StreamProvider {
public StreamProvider() {
}
}
App project:
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.com.a1ict.myapplication">
app/build.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile project(':app-debug')
}
app-debug/build.gradle: (name chosen by Android Studio when importing the lib):
configurations.maybeCreate("default")
artifacts.add("default", file('app-debug.aar'))
settings.gradle:
include ':app', ':app-debug'
Compilation & linking phase ends up well, just when the app is about to start I see in the logs:
08-31 13:16:30.386 6656-6656/au.com.a1ict.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: au.com.a1ict.myapplication, PID: 6656
java.lang.RuntimeException: Unable to get provider au.com.a1ict.mylib.provider.StreamProvider: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[zip file "/data/app/au.com.a1ict.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5002)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[zip file "/data/app/au.com.a1ict.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:4987)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534) 
at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-support-annotations-24.2.0_789c261ae08b7fa204bc7699aff21c5cfe4ba218-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_e6a045dc4d6d599e73e736c6e39e0dcf8f4490fd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_c96bb2006cae6009a151f1c7452e4a28bb4585dd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_a0d684a27f515a3bfd5243a957fad78a92e4fbcd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_369ab9945f1de9068baf3d6bc7fa4d034f59c368-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_2f9cbd5b7b19dc2598fd196e294d333d451c7a47-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-com.android.support-support-vector-drawable-24.2.0_ec6f782152c4bb5e3b0b6840a634e809e68482eb-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-com.android.support-support-v4-24.2.0_3e07c7a20cb62485a70
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: exClass=java.lang.ClassNotFoundException
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: exMsg=Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[zip file "/data/app/au.com.a1ict.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: file=BaseDexClassLoader.java
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: class=dalvik.system.BaseDexClassLoader
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: method=findClass line=56
08-31 13:16:30.426 6656-6656/au.com.a1ict.myapplication D/Error: ERR: stack=java.lang.RuntimeException: Unable to get provider au.com.a1ict.mylib.provider.StreamProvider: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[zip file "/data/app/au.com.a1ict.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5002)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[zip file "/data/app/au.com.a1ict.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:4987)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534) 
at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "au.com.a1ict.mylib.provider.StreamProvider" on path: DexPathList[[dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-support-annotations-24.2.0_789c261ae08b7fa204bc7699aff21c5cfe4ba218-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_e6a045dc4d6d599e73e736c6e39e0dcf8f4490fd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_c96bb2006cae6009a151f1c7452e4a28bb4585dd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_a0d684a27f515a3bfd5243a957fad78a92e4fbcd-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_369ab9945f1de9068baf3d6bc7fa4d034f59c368-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-internal_impl-24.2.0_2f9cbd5b7b19dc2598fd196e294d333d451c7a47-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-com.android.support-support-vector-drawable-24.2.0_ec6f782152c4bb5e3b0b6840a634e809e68482eb-classes.dex", dex file "/data/data/au.com.a1ict.myapplication/files/instant-run/dex/slice-com.android.support-support-v4-24.2.0_3e07c7a20cb62485a70a27026d0f6ed7d58d351e-classes.dex", dex file "/data/data/au.com.a1i
It must be related to the fact the component (StreamProvider) is located in the AAR file because when used in one project, it works flawlessly (same namespace, packages, ... -- I literally just copy library project's files into app-debug). Related SO questions mostly struggle with Eclipse. I'm really out of ideas here.
OK, this took one hell of an investigation but I have finally figured it out. It was actually a combination of several problems:
AAR doesn't contain information about its dependencies; so I either have to include them manually or setup a maven repository.
First I used maven-publish plugin for that only to realise it doesn't fill out AAR dependencies automatically.
Then I used Gradle Android Maven plugin, much better but:
Latest Gradle Android Maven plugin (1.5) requires Gradle 3.0+ while AS offers/recommends/sets 2.14.1 so I had to downgrade the plugin to 1.4.1
Then I realised that actually I still have to include https://s3.amazonaws.com/repo.commonsware.com dependency url into the app project because POM files do not contain information about repositories, only packages.
After that I finally don't see any crashes. Btw, I didn't have to use
compile ('com.group:artifact:0.0.1#aar'){transitive=true}
form (as suggested all over SO), specifying my dependency as:
compile ('com.group:artifact:0.0.1')
was enough.

How can my library import another library in Android Studio?

I am starting with libraries in Android, and I have managed to import a library in my app in this way:
add the .aar file in the /libs folder
add in build.gradle:
repositories{
flatDir {
dirs'libs'
}
dependencies {
...
compile(name:'mylibrary1',ext:'aar')
}
This works fine, but I made mylibrary2 and repeated steps 1 and 2 in mylibrary1, so now mylibrary1 could use mylibrary2.
In summary I want my app to import mylibrary1 and mylibrary1 to import mylibrary2.
The problem is in my app when I call a method from mylibrary2 I get an exception: java.lang.NoClassDefFoundError, I hope someone can help me
Here is the stackstrace in case it helps:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ar.com.tally.myapplication, PID: 30197
java.lang.NoClassDefFoundError: Failed resolution of: Lar/com/tally/mylibrary2/Class2;
at ar.com.tally.mylibrary1.Class1.get1(Class1.java:10)
at ar.com.tally.myapplication.MainActivity$1.onClick(MainActivity.java:28)
at android.view.View.performClick(View.java:5076)
at android.view.View$PerformClick.run(View.java:20279)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.ClassNotFoundException: Didn't find class "ar.com.tally.mylibrary2.Class2" on path: DexPathList[[dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-support-annotations-23.2.1_d668123607e57c7aa4406ba98a4276e21606428b-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-internal_impl-23.2.1_eca880fd3aaa2f093d820f9d7b8841aa1fa00b4f-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-intermediates-exploded-aar-mylibrary1_7763b008eb2396101d055fb29b3e03d5ee273add-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.2.1_5e6bcbbe4699b2a562a7ba7b6349f8bbfbef9fb4-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-support-v4-23.2.1_c564c185a6a1edef108674e96bf4712114e0c95a-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-recyclerview-v7-23.2.1_a1ec4cea5854a30b896e5f639d2fd95cd214b2b1-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-design-23.2.1_2c4b9902e86719e2bd0652ddfba695894bed0a47-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.2.1_01059d3db947a24736ebcedd233fd40b734ccf3e-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.2.1_69d3f470bac3bccd2f54179c6363fce8b9091976-classes.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at ar.com.tally.mylibrary1.Class1.get1(Class1.java:10) 
at ar.com.tally.myapplication.MainActivity$1.onClick(MainActivity.java:28) 
at android.view.View.performClick(View.java:5076) 
at android.view.View$PerformClick.run(View.java:20279) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5910) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "ar.com.tally.mylibrary2.Class2" on path: DexPathList[[zip file "/data/app/ar.com.tally.myapplication-1
So when you made mylibrary2 you changed mylibrary1 also so you need to replace both aars with the new ones clean and build again.
However if you have those libs in the same project as modules i recommend that you import them as projects instead of coping manually.
compile project(':mylibrary1')
compile project(':mylibrary2')
or if in different projects as in this case you can add mavenLocal() in repositories:
repositories {
mavenLocal()
...
}
and in your lib projects you can add the maven plugin:
apply plugin: 'maven'
then you need to call:
gradle install
which will install the libs in your local maven repo. so you don't need to copy them manually

Categories

Resources