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

Problem getting the settings robopod to work #106

Open
AgrarPirat opened this issue Mar 10, 2016 · 4 comments
Open

Problem getting the settings robopod to work #106

AgrarPirat opened this issue Mar 10, 2016 · 4 comments

Comments

@AgrarPirat
Copy link

Hello RoboVM Team,

I just tried to add the new settings robopod (1.14.0) to an existing project. While looking at the source of the settings example, I've noticed the following two lines of code at line 9 and 18 in MainActivity.java

import org.robovm.pods.android.AndroidConfig;
...
AndroidConfig.setLaunchActivity(this);

Now the problem is, that import org.robovm.pods.android.AndroidConfig; can't be found if it's added to the import statements at the projects main activity (android). Instead there seems to be a class org.robovm.pods.AndroidConfig;, but it seems to be empty, which causes the compiler to throw an error at: AndroidConfig.setLaunchActivity(this);

So I just tried to simply remove the two lines, which causes the app to compile, but crash because of:

  java.lang.AssertionError: java.lang.reflect.InvocationTargetException
            at org.robovm.pods.Platform.constructInstance(Platform.java:117)
            at org.robovm.pods.Platform.getInstance(Platform.java:79)
            at org.robovm.pods.Platform.getInstance(Platform.java:62)
            at org.robovm.pods.settings.Settings.<init>(Settings.java:20)
            at com.someapp.controller.AppSettings.<init>(AppSettings.java:72)
            at com.someapp.controller.AppSettings.getInstance(AppSettings.java:106)
            at com.someapp.WelcomeActivity.onCreate(WelcomeActivity.java:43)
            at android.app.Activity.performCreate(Activity.java:6251)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at org.robovm.pods.Platform.constructInstance(Platform.java:111)
            at org.robovm.pods.Platform.getInstance(Platform.java:79)
            at org.robovm.pods.Platform.getInstance(Platform.java:62)
            at org.robovm.pods.settings.Settings.<init>(Settings.java:20)
            at com.someapp.controller.AppSettings.<init>(AppSettings.java:72)
            at com.someapp.controller.AppSettings.getInstance(AppSettings.java:106)
            at com.someapp.WelcomeActivity.onCreate(WelcomeActivity.java:43)
            at android.app.Activity.performCreate(Activity.java:6251)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.app.Activity.getSharedPreferences(java.lang.String, int)' on a null object reference
            at org.robovm.pods.settings.AndroidSettings.setActivity(AndroidSettings.java:22)
            at org.robovm.pods.settings.AndroidSettings.<init>(AndroidSettings.java:18)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at org.robovm.pods.Platform.constructInstance(Platform.java:111)
            at org.robovm.pods.Platform.getInstance(Platform.java:79)
            at org.robovm.pods.Platform.getInstance(Platform.java:62)
            at org.robovm.pods.settings.Settings.<init>(Settings.java:20)
            at com.someapp.controller.AppSettings.<init>(AppSettings.java:72)
            at com.someapp.controller.AppSettings.getInstance(AppSettings.java:106)
            at com.someapp.WelcomeActivity.onCreate(WelcomeActivity.java:43)
            at android.app.Activity.performCreate(Activity.java:6251)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

This indicates that the call of AndroidConfig.setLaunchActivity(this); is required (well..., a pure guess). Do you have any ideas what could be wrong here? The dependencies in the build.gradle files look like this:
Core:
compile 'org.robovm:robopods-settings-core:1.14.0'
Android:
compile 'org.robovm:robopods-settings-android:1.14.0'
iOS:
compile 'org.robovm:robopods-settings-ios:1.14.0'

I couldn't figure out what's wrong here, by just looking at the example code, so any advice how to get the settings robopod running is welcome.
Thank you.

@BlueRiverInteractive
Copy link
Contributor

The latest version of AndroidConfig is not empty: Link
Could you try using the snapshot versions instead? This would be 1.14.1-SNAPSHOT.

@AgrarPirat
Copy link
Author

Thanks for the quick reply. I've changed the dependencies to:
Core:
compile 'org.robovm:robopods-settings-core:1.14.1-SNAPSHOT'
Android:
compile 'org.robovm:robopods-settings-android:1.14.1-SNAPSHOT'
iOS:
compile 'org.robovm:robopods-settings-ios:1.14.1-SNAPSHOT'

But this causes the following errors:

Error:Failed to resolve: org.robovm:robopods-settings-core:1.14.1-SNAPSHOT
Failed to resolve: org.robovm:robopods-settings-android:1.14.1-SNAPSHOT

Is there a special repository needed to access the snapshot?

@AgrarPirat
Copy link
Author

Any ideas what could be wrong here?

@AgrarPirat
Copy link
Author

I have no idea what's wrong here. Neither does my local AndroidConfig contain any code, nor can I access the snapshot version of the robopods. Deleting ~/.robovm and ~/.robovm-sdks didn't change anything. It seems like there's something wrong... maybe in the project structure? or in the build configuration? I don't know! Any advice is appreciated...

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

2 participants