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

Static binding generator crash build-time: clazz is null causes app to crash #665

Closed
roblav96 opened this issue Dec 22, 2016 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@roblav96
Copy link

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes.

Tell us about the problem

Recently cleaned out my project directory and now I'm having these build issues:

:asbg:generateInterfaceNamesList
:asbg:traverseJsFiles
:asbg:runAstParser
Running full build
finished with reading lines with js files
:asbg:generateBindings
java.lang.IllegalArgumentException: clazz is null
	at org.nativescript.staticbindinggenerator.ClassInfo.<init>(ClassInfo.java:25)
	at org.nativescript.staticbindinggenerator.ClassInfo.<init>(ClassInfo.java:20)
	at org.nativescript.staticbindinggenerator.ClassInfo.getSuperclass(ClassInfo.java:132)
	at com.tns.bindings.Dump.isApplicationClass(Dump.java:626)
	at com.tns.bindings.Dump.getSupportedMethods(Dump.java:323)
	at com.tns.bindings.Dump.generateProxy(Dump.java:211)
	at com.tns.bindings.ProxyGenerator.generateProxy(ProxyGenerator.java:36)
	at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:87)
	at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)
:mergeF0F1F2F3DebugShaders
:compileF0F1F2F3DebugShaders
:generateF0F1F2F3DebugAssets
:mergeF0F1F2F3DebugAssets

which results in the app crashing on launch.

Please provide the following version numbers that your issue occurs with:

┌──────────────────┬─────────────────┬────────────────┬─────────────┐
│ Component        │ Current version │ Latest version │ Information │
│ nativescript     │ 2.4.2           │ 2.4.2          │ Up to date  │
│ tns-core-modules │ 2.4.3           │ 2.4.3          │ Up to date  │
│ tns-android      │ 2.4.1           │ 2.4.1          │ Up to date  │
│ tns-ios          │ 2.4.0           │ 2.4.0          │ Up to date  │
└──────────────────┴─────────────────┴────────────────┴─────────────┘

Did the error happen while the app was being constructed? (buildtime error)

Yes. I tried doing --log trace but it flooded my terminal memory and couldn't capture it 😦
The app builds and deploys to device no problem.

Did the error happen while the app was executing? (runtime error)

Yes,

12-22 14:42:25.493 17606 17606 W System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
12-22 14:42:25.493 17606 17606 W System.err: Error calling module function 
12-22 14:42:25.493 17606 17606 W System.err: Error calling module function 
12-22 14:42:25.493 17606 17606 W System.err: Error: java.lang.ClassNotFoundException: com.tns.NativeScriptActivity
12-22 14:42:25.493 17606 17606 W System.err:     java.lang.Class.classForName(Native Method)
12-22 14:42:25.493 17606 17606 W System.err:     java.lang.Class.forName(Class.java:324)
12-22 14:42:25.493 17606 17606 W System.err:     java.lang.Class.forName(Class.java:285)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.Runtime.getClassForName(Runtime.java:947)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.ClassResolver.resolveClass(ClassResolver.java:50)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.Runtime.resolveClass(Runtime.java:565)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.Runtime.runModule(Native Method)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.Runtime.runModule(Runtime.java:514)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.Runtime.run(Runtime.java:509)
12-22 14:42:25.493 17606 17606 W System.err:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
12-22 14:42:25.493 17606 17606 W System.err:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
12-22 14:42:25.493 17606 17606 W System.err:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:4751)
12-22 14:42:25.493 17606 17606 W System.err:     android.app.ActivityThread.-wrap1(ActivityThread.java)
12-22 14:42:25.493 17606 17606 W System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
12-22 14:42:25.493 17606 17606 W System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
12-22 14:42:25.493 17606 17606 W System.err:     android.os.Looper.loop(Looper.java:148)
12-22 14:42:25.493 17606 17606 W System.err:     android.app.ActivityThread.main(ActivityThread.java:5461)
12-22 14:42:25.493 17606 17606 W System.err:     java.lang.reflect.Method.invoke(Native Method)
12-22 14:42:25.493 17606 17606 W System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-22 14:42:25.493 17606 17606 W System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-22 14:42:25.493 17606 17606 W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/com.gethuman.android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.gethuman.android-1/lib/arm, /data/app/com.gethuman.android-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
12-22 14:42:25.493 17606 17606 W System.err:     dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.ClassLoader.loadClass(ClassLoader.java:469)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.Class.classForName(Native Method)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.Class.forName(Class.java:324)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.Class.forName(Class.java:285)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.Runtime.getClassForName(Runtime.java:947)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.ClassResolver.resolveClass(ClassResolver.java:50)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.Runtime.resolveClass(Runtime.java:565)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.Runtime.runModule(Native Method)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.Runtime.runModule(Runtime.java:514)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.Runtime.run(Runtime.java:509)
12-22 14:42:25.494 17606 17606 W System.err:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
12-22 14:42:25.494 17606 17606 W System.err:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
12-22 14:42:25.494 17606 17606 W System.err:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:4751)
12-22 14:42:25.494 17606 17606 W System.err:     android.app.ActivityThread.-wrap1(ActivityThread.java)
12-22 14:42:25.494 17606 17606 W System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
12-22 14:42:25.494 17606 17606 W System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
12-22 14:42:25.494 17606 17606 W System.err:     android.os.Looper.loop(Looper.java:148)
12-22 14:42:25.494 17606 17606 W System.err:     android.app.ActivityThread.main(ActivityThread.java:5461)
12-22 14:42:25.494 17606 17606 W System.err:     java.lang.reflect.Method.invoke(Native Method)
12-22 14:42:25.494 17606 17606 W System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-22 14:42:25.494 17606 17606 W System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-22 14:42:25.494 17606 17606 W System.err: File: "/data/data/com.gethuman.android/files/internal/ts_helpers.js, line: 104, column: 28
12-22 14:42:25.494 17606 17606 W System.err: StackTrace: 
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'Interfaces.target.interfaces', file:'/data/data/com.gethuman.android/files/internal/ts_helpers.js', line: 104, column: 29
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'__decorate', file:'/data/data/com.gethuman.android/files/app/services/delegate/delegate.js', line: 10, column: 95
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'', file:'/data/data/com.gethuman.android/files/app/services/delegate/delegate.js', line: 84, column: 12
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'', file:'/data/data/com.gethuman.android/files/app/main.js', line: 9, column: 1
12-22 14:42:25.494 17606 17606 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266

Not sure what all that means 🤐

Please tell us how to recreate the issue in as much detail as possible.

Creating a new blank project does not produce this error; but I am extending the activity:

@JavaProxy('com.tns.NativeScriptActivity')
class Activity extends android.app.Activity {}

I'm in the midst of trial and error removing parts of the app trying to get it to build. lol

@petekanev
Copy link
Contributor

@roblav96 I was unable to make a fresh app crash using the aforementioned versions when extending a native activity.
Please paste the content of your root-level package.json here, also, navigate to \platforms\android\build-tools\android-static-binding-generator\bindings.txt and attach the file, thank you.

@roblav96
Copy link
Author

@Pip3r4o I too am unable to reproduce extending activity with a fresh app as well. Very strange :O

Also bindings.txt file does not exist in that directory nor any directory in platforms\android.

@petekanev
Copy link
Contributor

@roblav96 it is generated on build, if :asbg:runAstParser has passed, there should be bindings.txt somewhere in platforms/androd

@roblav96
Copy link
Author

@Pip3r4o I figured out the cause, bradmartin/nativescript-snackbar#16

@petekanev
Copy link
Contributor

@roblav96 responded in the issue you linked above, I believe to be a missing dependency to a particular version (22.2.0) of the design library.

@Plamen5kov Plamen5kov added the bug label Jan 6, 2017
@petekanev petekanev self-assigned this Jan 10, 2017
@petekanev petekanev changed the title Error on build java.lang.IllegalArgumentException: clazz is null causes app to crash Static binding generator crash build-time: clazz is null causes app to crash Jan 10, 2017
@petekanev
Copy link
Contributor

petekanev commented Jan 10, 2017

If the static-binding-generator throws an exception, it will not generate any pending classes, hence why there isn't a NativeScriptActivity at runtime. I am unable to cause the binding generator to crash build-time, so I am asking for your help.

Edit: the crash was reproduced successfully and a fix is underway.

@roblav96
Copy link
Author

@Pip3r4o ❤️

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

3 participants