Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: Could not initialize class components.Stark #60

Closed
efraespada opened this issue Aug 8, 2019 · 23 comments
Assignees
Labels

Comments

@efraespada
Copy link
Member

Just cloning this repo and building the project, we get this error:

java.lang.NoClassDefFoundError: Could not initialize class components.Stark
@efraespada
Copy link
Member Author

@ilyasdirin I cloned the repo again.
The sample project is building without problems on my computer.
Have you tried to invalidate the Android Studio cache and restart it?

@ilyasdirin
Copy link

@ilyasdirin I cloned the repo again.
The sample project is building without problems on my computer.
Have you tried to invalidate the Android Studio cache and restart it?

@efraespada I tried many times with clear, invalidate even macbook restart. I think it may uses some kind of java library because when I build it in windows it asks for java permission. can that libraries may be missing in mac?

@efraespada
Copy link
Member Author

It shouldn't.
The SC plugin uses native libraries (dll and dylib), which are loaded in the Stark class.
Dependencies on plugin:

dependencies {
    implementation gradleApi()
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    implementation group: 'com.google.guava', name: 'guava', version: '28.0-jre'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.1.0'
}

The stranger thing is that it is not working in both systems (Windows - MacOS).

@efraespada
Copy link
Member Author

@ilyasdirin did you build the app with ProGuard or R8 enabled?

@ilyasdirin
Copy link

@efraespada no I do not build app with ProGuard or R8. But if I achieve to build it I will eventually use it with proguard but for now I am not able to build it without proguard and R8.

@jiriklobasa
Copy link

jiriklobasa commented Oct 10, 2019

Did you find a solution to overcome this error @ilyasdirin?
Same happens to me with the latest version 3.5, tried on Mac OS 10.13.6 with Android Studio 3.5.1.
Any ideas @efraespada ? I have noticed that it happens just when you specify stringFilesoption.

@efraespada
Copy link
Member Author

efraespada commented Oct 14, 2019

Hi @jiriklobasa

Does this error only happen when stringFiles property is defined?

Are you getting any other error like this one?

Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595: dlopen(/private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595, 1): Symbol not found: __ZN5boost6system6detail24system_category_instanceE
  Referenced from: /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595
  Expected in: /usr/local/opt/boost/lib/libboost_system.dylib
 in /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595

@jiriklobasa
Copy link

jiriklobasa commented Oct 17, 2019

Hey @efraespada, yeah, from time to time this also appears. But when you clean the project up and rebuild it always ends with the java.lang.NoClassDefFoundError: Could not initialize class components.Stark error.
Just to add the statement - stringFiles property does not have impact on the error. You can just simply put an entry in strings.xml file with hidden="true" attribute and it crashes.

@klozMobile
Copy link

Hi @jiriklobasa

Does this error only happen when stringFiles property is defined?

Are you getting any other error like this one?

Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595: dlopen(/private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595, 1): Symbol not found: __ZN5boost6system6detail24system_category_instanceE
  Referenced from: /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595
  Expected in: /usr/local/opt/boost/lib/libboost_system.dylib
 in /private/var/folders/_t/ppptr4fs06gg1f38_bctzh3m0000gn/T/libsignKey.dylib5689898627273585595

I do

@efraespada
Copy link
Member Author

@klozMobile are you using a macOS system?
If that's the case, have you recently upgrade your system?

@MostafaAnter
Copy link

Screen Shot 2019-12-30 at 4 26 13 PM

Same problem with me

@MostafaAnter
Copy link

@efraespada yes I'm using macOS catalina

@MostafaAnter
Copy link

after many trying, I think this problem com when to add cpp folder and add some native code to project I think there is some conflict with your project native code and our project I hope that help thanks in advanced

@efraespada
Copy link
Member Author

efraespada commented Dec 31, 2019

@MostafaAnter you are right. I've created a native C++ project and added SC. It returns the java.lang.UnsatisfiedLinkError error at runtime.

SC uses the default name for the native library (native-lib) and your native library overrides it.

I've just released v3.6.2 with a different native library name.

Thank you so much @MostafaAnter for your report 🙌


@jiriklobasa @klozMobile @ilyasdirin do you have a similar project case?

@MostafaAnter
Copy link

MostafaAnter commented Dec 31, 2019

@efraespada so far so good now I can reveal and obfuscate any text on kotlin files but I still can't do hidden to my strings on res folder so this error show to me Library not loaded: /usr/local/opt/boost/lib/libboost_system.dylib
Screen Shot 2019-12-31 at 11 58 11 AM
now I guess that is happened because of JDK on my device, so there is any suggestions

@efraespada
Copy link
Member Author

efraespada commented Dec 31, 2019

I think It's an error on the G++ compiler flags, some native libraries were not included in the SC native lib for macOS systems.
@MostafaAnter try with v3.6.3.

@guillermog888
Copy link

Hi @efraespada, I have the same problem and I downloaded v3.6.3 but I have the same error whit v3.6.2

Library not loaded: /usr/local/opt/boost/lib/libboost_system.dylib
Referenced from: /private/var/folders/rd/d5t6kngn69b4czf58f_8cxtr0000gn/T/libsignKey.dylib682191099424347482

@efraespada
Copy link
Member Author

Could you try v4.0.0?
There is a new implementation, the plugin is applied per module:

apply plugin: 'com.android.application'
apply plugin: StringCare

stringcare {
    debug true
    assetsFiles = ["*.json"]
    stringFiles = ['strings.xml']
    srcFolders = ['src/main']
}

android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

repositories {
    jcenter()
}

dependencies {
    implementation "com.stringcare:library:$stringcare_version"
}

@guillermog888
Copy link

Hi @efraespada the v4.0.0 works for me but i have one question im trying to obfuscate the strings but the project have different project modules and i can't obfuscate the string of the others modules thanks

@efraespada
Copy link
Member Author

@guillermog888 I think that's because the plugin only controls (by the moment) the application module:

apply plugin: 'com.android.application'
apply plugin: StringCare

I'll try to fix that.

@efraespada
Copy link
Member Author

@guillermog888 I've created another issue with that problem:

- Library Support

I close this one.

@haitv2910
Copy link

Hi @efraespada, I have the same problem and I downloaded v4.2.1 but I have the same error whit v4.2.1
I'm using macOS

@efraespada
Copy link
Member Author

@haitv2910 in which modules you were using Stringcare?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants