First I want to say thanks for making this library. It's working awesome on iOS!!
I'm struggling to make it work for Android though. It seems like the readme for Android breaks down half way and assumes knowledge of the Android ecosystem.
I'm also happy to PR fixes to the readme once I can figure out what's missing.
React Native 0.30
React 15.2.0
react-native-navigation 2.0.0-experimental.71
Firstly the readme says to run npm install react-native-navigation --save
but that installs version 1.X. This works for iOS but fails on Android with a missing Splash module.
An hour later I figured out that I needed the 2.0 beta and installed that. Steps 1 and 2 and great and didn't have any issues with that.
Step 3 assumes you know where to locate MainActivity
. Then after extending the class I hit a missing symbol error and guessed at importing the missing file (and also later confirmed by looking at the redux example).
Step 4 completely loses me but i've figured out how to at least make the compiler work... though the app launches with "Foo stopped running" so I must be doing something wrong here.
My fresh app had a MainApplication.java
file which I commented out and added an App.java
file like your examples. I added in the custom class (with name of App instead of MyApplication) and changed the xml file. The instructions for changing the XML is not enough for a non Android dev. I guessed by looking at the example.
Ultimately I still can't get the app to work on an upgraded RN 0.30 install (and used react-native upgrade).
Here are my changed Android files:
added android:name=".App"
to config
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.badger">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".App"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
package com.badger;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
}
// ..../com/badger/App.java
package com.badger;
import android.support.annotation.NonNull;
import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;
import java.util.Collections;
import java.util.List;
public class App extends NavigationApplication {
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
@NonNull
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return Collections.emptyList();
}
}
// ..../com/badger/MainApplication.java
/*
package com.badger;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
*/
With the logger running I get this once starting up:
08-21 16:28:57.672 2577 2577 E AndroidRuntime: FATAL EXCEPTION: main
08-21 16:28:57.672 2577 2577 E AndroidRuntime: Process: com.badger, PID: 2577
08-21 16:28:57.672 2577 2577 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.badger.App: java.lang.ClassNotFoundException: Didn't find class "com.badger.App" on path: DexPathList[[zip file "/data/app/com.badger-2/base.apk"],nativeLibraryDirectories=[/data/app/com.badger-2/lib/x86, /data/app/com.badger-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.ActivityThread.-wrap1(ActivityThread.java)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.badger.App" on path: DexPathList[[zip file "/data/app/com.badger-2/base.apk"],nativeLibraryDirectories=[/data/app/com.badger-2/lib/x86, /data/app/com.badger-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.Instrumentation.newApplication(Instrumentation.java:981)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: ... 9 more
08-21 16:28:57.672 2577 2577 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: com.badger.App
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-21 16:28:57.672 2577 2577 E AndroidRuntime: ... 12 more
08-21 16:28:57.672 2577 2577 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Very confused... any help would be appreciated!!