0

Ich habe ein Problem mit Cordova Anwendung sowohl auf Emulator und einem Android-Gerät ausgeführt. Es ist eine App mit Phonegap-Vorlage-Reagieren-Hot-Loader-Vorlage erstellt.Runtime Exception beim Ausführen von Cordova App

Hier ist ein adb log:

E/AndroidRuntime(2704): FATAL EXCEPTION: main 
E/AndroidRuntime(2704): Process: com.cphoto.pl, PID: 2704 
E/AndroidRuntime(2704): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cphoto.pl/com.cphoto.pl.MainActivity}: java.lang.StringIndex 
OutOfBoundsException: length=0; index=0 
E/AndroidRuntime(2704):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 
E/AndroidRuntime(2704):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
E/AndroidRuntime(2704):  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
E/AndroidRuntime(2704):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
E/AndroidRuntime(2704):  at android.os.Handler.dispatchMessage(Handler.java:102) 
E/AndroidRuntime(2704):  at android.os.Looper.loop(Looper.java:136) 
E/AndroidRuntime(2704):  at android.app.ActivityThread.main(ActivityThread.java:5017) 
E/AndroidRuntime(2704):  at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime(2704):  at java.lang.reflect.Method.invoke(Method.java:515) 
E/AndroidRuntime(2704):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
E/AndroidRuntime(2704):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
E/AndroidRuntime(2704):  at dalvik.system.NativeStart.main(Native Method) 
E/AndroidRuntime(2704): Caused by: java.lang.StringIndexOutOfBoundsException: length=0; index=0 
E/AndroidRuntime(2704):  at org.apache.cordova.ConfigXmlParser.setStartUrl(ConfigXmlParser.java:139) 
E/AndroidRuntime(2704):  at org.apache.cordova.ConfigXmlParser.handleStartTag(ConfigXmlParser.java:116) 
E/AndroidRuntime(2704):  at org.apache.cordova.ConfigXmlParser.parse(ConfigXmlParser.java:75) 
E/AndroidRuntime(2704):  at org.apache.cordova.ConfigXmlParser.parse(ConfigXmlParser.java:63) 
E/AndroidRuntime(2704):  at org.apache.cordova.CordovaActivity.loadConfig(CordovaActivity.java:158) 
E/AndroidRuntime(2704):  at org.apache.cordova.CordovaActivity.onCreate(CordovaActivity.java:111) 
E/AndroidRuntime(2704):  at com.cphoto.pl.MainActivity.onCreate(MainActivity.java:30) 
E/AndroidRuntime(2704):  at android.app.Activity.performCreate(Activity.java:5231) 
E/AndroidRuntime(2704):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
E/AndroidRuntime(2704):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
E/AndroidRuntime(2704):  ... 11 more 
D/dalvikvm(2563): DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS 
W/dalvikvm(2563): VFY: unable to resolve static field 2750 (SUPPORTED_ABIS) in Landroid/os/Build; 
D/dalvikvm(2563): VFY: replacing opcode 0x62 at 0x0008 
D/dalvikvm(2563): GC_CONCURRENT freed 532K, 18% free 5407K/6528K, paused 12ms+9ms, total 39ms 
E/MDM  (2563): [120] pwk.a: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null} 
W/ActivityManager(1817): Force finishing activity com.cphoto.pl/.MainActivity 

AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?> 
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.cphoto.pl" xmlns:android="http://schemas.android.com/apk/res/android"> 
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true"> 
     <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize"> 
      <intent-filter android:label="@string/launcher_name"> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"> 
      <intent-filter> 
       <action android:name="com.phonegap.plugins.barcodescanner.SCAN" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity android:label="@string/share_name" android:name="com.google.zxing.client.android.encode.EncodeActivity"> 
      <intent-filter> 
       <action android:name="com.phonegap.plugins.barcodescanner.ENCODE" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity android:label="@string/share_name" android:name="com.google.zxing.client.android.HelpActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.VIEW" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
    </application> 
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" /> 
    <uses-permission android:name="android.permission.CAMERA" /> 
    <uses-permission android:name="android.permission.FLASHLIGHT" /> 
    <uses-feature android:name="android.hardware.camera" android:required="false" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
</manifest> 

config.xml

<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.cphoto.pl" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> 
    <name>Cphoto</name> 
    <description> 
     Cordova Photo React Hot Reloader 
    </description> 
    <author email="[email protected]" href="https://github.com/kmiasko"> 
     Kmiasko 
    </author> 
    <preference name="permissions" value="none" /> 
    <preference name="orientation" value="default" /> 
    <preference name="target-device" value="universal" /> 
    <preference name="DisallowOverscroll" value="true" /> 
    <preference name="detect-data-types" value="true" /> 
    <preference name="android-minSdkVersion" value="19" /> 
    <preference name="android-installLocation" value="auto" /> 
    <platform name="android"> 
...icons 
    </platform> 
    <platform name="ios"> 
...icons 
    </platform> 
    <platform name="wp8"> 
...icons 
    </platform> 
    <platform name="windows"> 
...icons 
    </platform> 
    <access origin="*" /> 
    <allow-intent href="http://*/*" /> 
    <allow-intent href="https://*/*" /> 
    <allow-intent href="tel:*" /> 
    <allow-intent href="sms:*" /> 
    <allow-intent href="mailto:*" /> 
    <allow-intent href="geo:*" /> 
    <platform name="android"> 
     <content src="" /> 
     <allow-intent href="market:*" /> 
     <allow-navigation href="*" /> 
    </platform> 
    <plugin name="cordova-plugin-whitelist" version="1" /> 
    <plugin name="cordova-plugin-statusbar" spec="~2.1.0" /> 
    <plugin name="cordova-plugin-console" spec="~1.0.4" /> 
    <plugin name="cordova-plugin-crosswalk-webview" spec="~2.1.0"> 
     <variable name="XWALK_VERSION" value="21+" /> 
     <variable name="XWALK_LITEVERSION" value="xwalk_core_library_canary:17+" /> 
     <variable name="XWALK_COMMANDLINE" value="--disable-pull-to-refresh-effect" /> 
     <variable name="XWALK_MODE" value="embedded" /> 
     <variable name="XWALK_MULTIPLEAPK" value="true" /> 
    </plugin> 
    <plugin name="cordova-plugin-camera" spec="~2.3.0" /> 
    <engine name="android" spec="~5.2.2" /> 
</widget> 
+0

Pls den Code für com.cphoto.pl.MainActivity liefern, da die Ausnahme, sagt StringIndexOutOfBoundsException in Zeile 30 der com.cphoto.pl.MainActivity Klasse aufgetreten –

+0

ich es Sie nicht denken, wird etwas sagen, dann ist es cordova Android-Plattform erzeugt Datei. 'import android.os.Bundle; import org.apache.cordova. *; public class MainActivity erweitert CordovaActivity { @Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); // Set von in der config.xml loadUrl (launchUrl); } } ' – kmiasko

Antwort

0

Das Problem war, dass NPM-Skripte aus der Vorlage Config geändert. xml und geändert <content src="index.html" /> bis <content src="http://10.0.2.2:8080" /> so Android Gerät/Emulator wurde nicht mit der Datei index.html serviert.

Verwandte Themen