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

The app referencing is getting huge, Android and iOS #1542

Closed
AntonioCuevaUrraco opened this issue Feb 25, 2016 · 10 comments
Closed

The app referencing is getting huge, Android and iOS #1542

AntonioCuevaUrraco opened this issue Feb 25, 2016 · 10 comments

Comments

@AntonioCuevaUrraco
Copy link

So Smarp is a pay customers of Zendesk and @sitefinitysteve have done a great work in collaboration with the zendesk team to make it work for NS. Hence I add it to the platform and the build reached the 65k dex limit for android.

Unable to execute dex: method ID not in [0, 0xffff]: 65536
And I have to modify the build.gradle to fix it as instructed here http://developer.android.com/intl/zh-tw/tools/building/multidex.html

In the other side xcode doesn't want to upload the app to the store anymore. At first I though it is like always their servers too overloaded but after a day of retry and retry I used the application loader and it got in but with this warning
screen shot 2016-02-25 at 9 35 35 am

So after all this story, Is there something I can do to reduce the number of references? I am not really sure what kind of things make the references increase as I only manage the .js layer.

Also I hope you take this into account for further releases and this thing dosn't break the android building

@AntonioCuevaUrraco
Copy link
Author

@Plamen5kov What do you think about letting the app.gradle to add defaultConfig to the platform build.gradle?

Somethng like this

dependencies {
    // Enabling multidex support.
    compile 'com.android.support:multidex:1.0.0'
}

defaultConfig {
        // Enabling multidex support.
        multiDexEnabled true
}

@Plamen5kov
Copy link
Contributor

Hi, @AntonioCuevaUrraco
I'd say it's a good idea, but to enable more then 65536 references you'd need to do more than just change the default config as is described in the link you provided. One of those obstacles is:

public void onCreate(Bundle arguments) {
    MultiDex.install(getTargetContext()); // this can't be reached by the user yet
    super.onCreate(arguments);
    ...
}

but i think you will be glad to hear we are making changes so that it is possible with this: NativeScript/android#364 which will enable the user to change the onCreate implementation through the javascript code.

We already have an issue oppended: NativeScript/android#344 and we are working on it.
About your question So after all this story, Is there something I can do to reduce the number of references?
First of all let me say that the number of references depends on what libraries you are importing. The bigger the library the more references there are.
To answer your question: Yes you can do something about it. When adding dependencies to libraries like so:

dependencies {
    compile 'com.google.android.gms:play-services:8.4.0'
}

this adds the whole google play services library and it's a big one, although you might not need to. The solution is to get (if possible) only the parts you need like so:

dependencies {
    compile 'com.google.android.gms:play-services-fitness:8.4.0'
}

You can read more here: https://developers.google.com/android/guides/setup
Keep in mind not all dependencies are separated in such an orderly manner and it's not always possible to import just parts of a library, but in most cases the libraries aren't that big.

@AntonioCuevaUrraco
Copy link
Author

Thank you @Plamen5kov I didn't know about the onCreate but the thing is that after the changes on gradle the build went thought and seams all good :-/ weird but I will have to check it out before releasing a new version in case there is some hided crash waiting for a user to click something.

We have around 10 plugins and I think Fb is the fattest guy on the room I will check if I can do something about it

@NathanWalker
Copy link
Contributor

@AntonioCuevaUrraco The App Store message above is "informational" only. I get the message everytime we upload a version of our hybrid app which uses several plugins but it always publishes to the store just fine.

@AntonioCuevaUrraco
Copy link
Author

I got now this one:

java.lang.OutOfMemoryError: GC overhead limit exceeded

So I had to add to build.gradle

dexOptions {
    javaMaxHeapSize "4g"
}

@AntonioCuevaUrraco
Copy link
Author

@Plamen5kov I have some crash reports like this
Android 4.2 --> 71.4%
Android 4.4 --> 28.6%

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
Calling js method onCreate failed
Error: java.lang.NoClassDefFoundError: org.ow2.asmdex.structureWriter.ConstantPool
    org.ow2.asmdex.ApplicationWriter.<init>(ApplicationWriter.java:115)
    com.tns.bindings.ProxyGenerator.generateProxy(ProxyGenerator.java:50)
    com.tns.DexFactory.generateDex(DexFactory.java:258)
    com.tns.DexFactory.resolveClass(DexFactory.java:106)
    com.tns.ClassResolver.resolveClass(ClassResolver.java:31)
...
...
...
File: "/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/application/application.js, line: 7, column: 29
StackTrace: 
    Frame: function:'initEvents', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/application/application.js', line: 7, column: 30
    Frame: function:'AndroidApplication.init', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/application/application.js', line: 121, column: 29
    Frame: function:'app.init.onCreate', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/application/application.js', line: 217, column: 24

I think it may be related to the multidex issue, What do you think?
is it solve on 2.0? some advice? I will start updating immediately

@Plamen5kov
Copy link
Contributor

Hi @AntonioCuevaUrraco,
Could you give me additional information:

  • Can you provide a repo with the project, so we can easily reproduce your problem, because currently I can't.
  • What changes have you made, can you give us the steps?
  • Did the application work before the 2.0 release, or started blowing up after a change you made?
  • Android 4.2 --> 71.4% | Android 4.4 --> 28.6%
    do these percentages mean that the problem is not occurring always, but often enough?

@AntonioCuevaUrraco
Copy link
Author

AntonioCuevaUrraco commented May 3, 2016

I have the client on 1.6.0, android 1.6.3 and iOs 1.6.0.
I can't give you a link to the repo as it is happening on the app we have on the market.
I activated the multidex on build.gradle and is all good on devices running lollipop and up, but older devices crash
The numbers means in which android versions the crash is happening, 71% of the time is happening on android 4.2
What I did to solve the problem for now is:
Update nativescript-push-notifications to the latest version that reduce the dex
remove this lines that I had before on the build.gradle

dependencies {
    // Enabling multidex support.
    compile 'com.android.support:multidex:1.0.0'
}

defaultConfig {
        // Enabling multidex support.
        multiDexEnabled true
}

The thing is that I solve it by avoiding the multidex but as the app keep growing I will hit the limit again, and as I could read you made a solution that was released on 2.0. I wanted to confirm and if there is some guideline about using multidex with NS

Thank you for your time @Plamen5kov

I have been using this too tool to check the numbers on the dex https://github.com/mihaip/dex-method-counts and I get a result of method count: 44979

@Plamen5kov
Copy link
Contributor

Hi @AntonioCuevaUrraco,
If you wan't to enable multidex support, you need to do a couple more things described here. You can see a working multidex support example here. The example works with ^2.0 release.

@AntonioCuevaUrraco
Copy link
Author

Thank you for the working sample. I think the issue is solved now

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

No branches or pull requests

3 participants