tom91136 / Akatsuki

Android states and arguments made easy with annotations
Apache License 2.0
138 stars 15 forks source link

Many NoClassDefFoundError #1

Closed Ivolian closed 9 years ago

Ivolian commented 9 years ago

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

java.lang.NoClassDefFoundError: com/github/mustachejava/MustacheFactory

tom91136 commented 9 years ago

Hi, thanks for trying out the library! What does your build.gradle look like? Did you download the library and build it locally or used something like jitpack?

Ivolian commented 9 years ago

Thanks for your reply.

I download jars and build.gradle look like: compile files('libs/akatsuki-api-0.0.1.jar') apt files('libs/akatsuki-compiler-0.0.1.jar')

And so many NoClassDefFoundError come out. Such as: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableSet. I cope one, and another happen.

I try using "transitive = true" , but not work.

tom91136 commented 9 years ago

Oops, my bad, the gradle task is a bit flaky. Right now the final jar doesn't contain the dependencies. (This is why you see all those NoClassDefFoundError). It'll upload the artifact in a few hours time and update the readme(there're two more tests that I need to finish).

If you want to try right now, follow the instructions: execute the following in the root of the library

gradlew clean :akatsuki-api:install :akatsuki-compiler:install :akatsuki-parceler:install

Akatsuki should now be installed in your local maven repo, add the following:

compile 'com.sora.util.akatsuki:akatsuki-api:0.0.1'
apt 'com.sora.util.akatsuki:akatsuki-compiler:0.0.1'
compile 'com.sora.util.akatsuki:akatsuki-parceler:0.0.1@aar'

And don't forget to add maven local to your repositories:

 allprojects {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal() // <-- this
    }
}

You can skip parceler if you don't need that

When the artifact is ready, I'll let you know and then you can remove mavenLocal()

tom91136 commented 9 years ago

JCenter approved my project but there seems to be some strange issues on their side so I can't upload properly. I'll get this sorted ASAP.

tom91136 commented 9 years ago

Artifact successfully uploaded and it's working on my side so I'm closing; feel free to reopen if it's not working for you.

ersin-ertan commented 9 years ago

apt 'com.sora.util.akatsuki:akatsuki-compiler:0.0.1' This line is not working for me. Crashes straight away with:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nullcognition.akatsuki/com.nullcognition.akatsuki.ActivityMain}: java.lang.ClassNotFoundException: Didn't find class "com.nullcognition.akatsuki.ActivityMain" on path: DexPathList[[zip file "/data/app/com.nullcognition.akatsuki-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
...
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available 
tom91136 commented 9 years ago

Can you show me the source for ActivityMain.java? (Or just the part involving Akatsuki)

On Mon, 24 Aug 2015 4:22 am Ersin Ertan notifications@github.com wrote:

apt 'com.sora.util.akatsuki:akatsuki-compiler:0.0.1' This line is not working for me. Crashes straight away with:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nullcognition.akatsuki/com.nullcognition.akatsuki.ActivityMain}: java.lang.ClassNotFoundException: Didn't find class "com.nullcognition.akatsuki.ActivityMain" on path: DexPathList[[zip file "/data/app/com.nullcognition.akatsuki-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] ... Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

— Reply to this email directly or view it on GitHub https://github.com/tom91136/Akatsuki/issues/1#issuecomment-133921480.

ersin-ertan commented 9 years ago

Just the apt Here is ActivityMain

tom91136 commented 9 years ago

Perfect, I will download and try to recreate.

On Mon, 24 Aug 2015 4:38 am Ersin Ertan notifications@github.com wrote:

Just the apt Here is ActivityMain https://github.com/ersin-ertan/android-architecture/tree/master/akatsuki/src/main/java/com/nullcognition/akatsuki

— Reply to this email directly or view it on GitHub https://github.com/tom91136/Akatsuki/issues/1#issuecomment-133928095.

tom91136 commented 9 years ago

Umm, I tried to build your project and it worked fine(I removed the comments). Here's the output from gradle:

>android-architecture-master\android-architecture-master>gradlew :akatsuki:clean :akatsuki:installDebug --refresh-dependencies
:akatsuki:clean
:akatsuki:preBuild UP-TO-DATE
:akatsuki:preDebugBuild UP-TO-DATE
:akatsuki:checkDebugManifest
:akatsuki:prepareDebugDependencies
:akatsuki:compileDebugAidl
:akatsuki:compileDebugRenderscript
:akatsuki:generateDebugBuildConfig
:akatsuki:generateDebugAssets UP-TO-DATE
:akatsuki:mergeDebugAssets
:akatsuki:generateDebugResValues UP-TO-DATE
:akatsuki:generateDebugResources
:akatsuki:mergeDebugResources
:akatsuki:processDebugManifest
:akatsuki:processDebugResources
:akatsuki:generateDebugSources
:akatsuki:processDebugJavaRes UP-TO-DATE
:akatsuki:compileDebugJava
Note: round has no elements, classes possibly originated from another annotation processor. Root:[]
Note: round has no elements, classes possibly originated from another annotation processor. Root:[]
Note: C:\Users\Tom\Downloads\android-architecture-master\android-architecture-master\akatsuki\build\generated\source\apt\debug\com\sora\util\akatsuki\AkatsukiMapping.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:akatsuki:compileDebugNdk UP-TO-DATE
:akatsuki:compileDebugSources
:akatsuki:preDexDebug
:akatsuki:dexDebug
:akatsuki:validateDebugSigning
:akatsuki:packageDebug
:akatsuki:zipalignDebug
:akatsuki:assembleDebug
:akatsuki:installDebug
Installing APK 'akatsuki-debug.apk' on 'Nexus 6 - 5.1.1'
Installed on 1 device.

BUILD SUCCESSFUL

Total time: 54.729 secs

The installed apk with the sample string also worked fine.

Could you please use the gradle CLI to build on your side? Also, what's your IDE setup? (eg, Android Studio w/ JDK 7...)

ersin-ertan commented 9 years ago

I'm getting passing builds from the CLI with ./gradlew assembleDebug in Android Studio, open JDK 7, but the same crash when I run on the emulator

Adding multiDexEnabled in the build.gradle, then ./gradlew assembleDebug lead to:

Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1
tom91136 commented 9 years ago

The annotation processor is written in Java 8 so you might want to use JDK8 (TravisCI uses oraclejdk8). Can you provide more info? This is looking more like a multiDex issue. Your sample app runs fine on API22 on my side. What API level is your emulator?

ersin-ertan commented 9 years ago

Tried both the Genymotion and stock emulator at API level 22. Downloaded Oracle JDK 1.8.0_60 and changed project structure to point to it. Tried adding compile for JavaVersion.VERSION_1_8 which lead to:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
...
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/jdk1.8.0_60/bin/java'' finished with non-zero exit value 1

Removed muliDexEnabled, removed compileVersion, now exactly like the original build.gradle. Cleaned the project, make project, it worked Switched the project structure to point to Open Jdk, and invalidated and restarted Android Studio, and it still worked... Good bye half a day, now I'll be happy to try you lib out.

tom91136 commented 9 years ago

Weird things happen with Android studio. When in doubt, compile in CLI first to make sure the build actually works. Also, it's my bad that I didn't specify the minimum requirement for JDK. I'll put it in the README. Sorry for wasting your time.

ersin-ertan commented 9 years ago

Hey I was happy to help an open source project(I was simply surprised it took that long). Don't mention it

For anyone that might read this, exact step to reproduce the problem was as follows:

tom91136 commented 9 years ago

With commit fdb200c7af76bf1015e52bb53225b5eeea1366a0 JDK requirements are now clear

FusEcho commented 8 years ago

I have solved the problem by setting the options in build.gradle: compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } my locale jdk is openjdk-1.8 when i create the project the version is 1.6.