I am having an external library (constants.aar) file. I have kept this .aar file in to my Android library module project's (sdk-module)/lib folder. This sdk-module has classes which uses methods from constants.aar.
Compiling the sdk-module generates sdk-module.aar file.
In my application i am including this sdk-module.aar file. When i am trying to use certain class files of sdk-module, i am getting NoClassDefFoundError.
java.lang.NoClassDefFoundError: Failed resolution of: "class file from constant.aar";
Caused by: java.lang.ClassNotFoundException: Didn't find class "xyz" on path:
I have unzipped the sdk-module.aar file and i can see that constants.aar file is available in its /lib folder.
How to resolve this issue?
android {
defaultConfig {
....
multiDexEnabled true // Add this line in your build.gradle file
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Extend : MultiDexApplication Class In in your ApplicationClass.java
public class BusinessCardApplication extends MultiDexApplication { ... }
OR
MultiDex.install(this); //add this line
Either, See this library's Issues File. If It Is from library's issue there is also define this error detail
Related
I've created a project with one module. e.g
app
module
When I'm using the following code in the app's build.gradle, It's working fine
implementation project(':module')
When I'm creating .aar for module with minifyEnabled true and using it in build.gradle using bellow code
implementation files('module-release.aar')
It gives the following error
Caused by: java.lang.ClassCastException: com.mypackage.DaggerMainApplication_HiltComponents_ApplicationC$ActivityRetainedCImpl$ActivityCImpl cannot be cast to com.com.mypackage.MyActivity_GeneratedInjector
Now there is a third-party dependency package: page
It has an interface that contains the default method :
public interface TempInterface {
default String getStr() {
return "test";
}
}
And i create a module : app
There is a class in "app" that uses the above interface
public class AA implements TempInterface {
}
"build.gradle" file in "app" :
dependencies {
compileOnly project(':page')
}
In the generated APK, the following classes appear:
what about *$-CC ?????
And when I decompiled the DEX file, I found that there was no such class at all:
So I'm confused about what this "* $- CC" is ??
Who can help me
the build.gradle :
$-CC file is generated by d8 when the class file compile to dex file.
More details on https://mouaad.aallam.com/java-8-interface-methods-for-android/
why you apply proguard from your app/build.gradle, it obfuscates your class and methods name so that reverse engineering is tough. that is what happens here
I have an Android project, inside I have a library module, my project works fine, compile the project I get the .aar included in a test project and everything ok.
Now,I have added in my library module a Activity that extends Application, Y Added this class in the manifiest.xml of the library
<application
android:allowBackup="true"
android:label="#string/app_name"
android:name=".MyActivityExtendsApplications"
When I test the project it works perfect, but when I take the .aar and test it on other project fails. The problem is that it does not find the activity extend Application ... I have decompiled the aar and I see that everything is correct, all class are inside the folder
The error is
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mylibrary.MyActivityExtendsApplications" on path: DexPathList[[zip file "/data/app/com.myapplication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapplication-1/lib/arm, /vendor/lib, /system/lib]]
Suppressed: java.lang.ClassNotFoundException: com.mylibrary.MyActivityExtendsApplications
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
I adding grandle dependency to library .aar In all cases in the same way
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'mylibrary-debug.mylibrary-debug#aar'
}
repositories{
flatDir{
dirs 'libs'
}
}
I check merged manifest in my test Project and the activity is there
application
android:name="com.mylibrary.MyActivityExtendsApplications"
android:allowBackup="true"
And I can import this Activity in my test Project and see the code
And I added mylibrary in libs folder.
When I remove the activity MyActivityExtendsApplications, my library works fine.
The issue may be the the Android Beacon Library aar files are missing when you generate your library aar, and the exception description is simply misleading. I don't think classes from aar files are automatically merged when generating a new aar file. You might check to see if these files (like Beacon.class) are missing from your aar.
If this is indeed the problem, there are two possible solutions:
In your application, reference both your library aar file and the Android Beacon Library aar file.
Merge the classes from the first aar file into your new aar file. I have done this before with rather a rather inelegant shell script that I am happy to share, but there may be a better way to accomplish the same thing.
I've created a library to be released as an aar. In this library I'm using Facebook Stetho so in my library dependencies I'm using:
compile "com.facebook.stetho:stetho:1.4.1"
I've also added the following lines to my library proguard file:
-keep class com.facebook.stetho.** { *; }
-dontwarn com.facebook.stetho.**
After the aar is generated I'm incorporating it on a app using Android Studio File -> New Module -> Import .JAR/.AAR so
compile project(':MyTestProject')
Is added to the app build.gradle file.
When I run the app, the app crashes with the log
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/stetho/Stetho;
....
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.stetho.Stetho" on path:.....
If I add the compile "com.facebook.stetho:stetho:1.4.1" dependency to the app build.gradle is working as expected.
Any idea why?
I'm new in the world Gradle.
I created the form "MyApp" and the module "Library".
Inside the module "Library" I have a. Jar inside the Libs folder and inside I build.gradle:
dependencies {
compile FileTree (dir: 'libs', includes: ['*. jar'])
}
But the. Jar goes into error during compilation:
Error: (108, 9) error: can not find symbol class JAXBContext.
What is wrong?
thanks