0

I have written my own plugin for cordova and the building process works without problems 'cordova run android' (BUILD SUCCESSFUL).

For starting purpose I just want to open another activity after clicking a button in my index.html. Unfortunately the app crashes as soon as it calls the other activity; I think there might be a mistake in my plugin.xml (it does maybe not include everything). The activity that I want to start works perfectly fine in Android Studio and on my real android device.

Here is my plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="com.matd.coolplugin"
    version="0.2.11">
    <name>CoolPlugin</name>
    <description>The coolest Plugin ever implemented</description>
    <license>Apache 2.0</license>
    <keywords>cordova,coolest</keywords>
    <repo></repo>
    <issue></issue>

    <js-module src="www/CoolPlugin.js" name="CoolPlugin">
        <clobbers target="CoolPlugin" />
    </js-module>

    <!-- android -->
    <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="CoolPlugin" >
                <param name="android-package" value="theUser.multibarcode.CoolPlugin"/>
            </feature>
        </config-file>

        <!-- manifest einstellungen -->
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <activity
            android:name="theUser.multibarcode.MultiTrackerActivity"
            android:label="Multi-Tracker"
            android:screenOrientation="fullSensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

     </config-file>
     <config-file>
     <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode,face" />
     </config-file>

     <config-file target="AndroidManifest.xml" parent="/manifest">

     <uses-feature android:name="android.hardware.camera" />
     <uses-permission android:name="android.permission.CAMERA" />

     </config-file>


        <source-file src="src/android/src/theUser/multibarcode/CoolPlugin.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/BarcodeTrackerFactory.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/FaceTrackerFactory.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/GraphicTracker.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/MultiTrackerActivity.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/TrackedGraphic.java" target-dir="src/" />
        <source-file src="src/android/src/theUser/multibarcode/ui/camera/CameraSourcePreview.java" target-dir="src/ui/camera/" />
        <source-file src="src/android/src/theUser/multibarcode/ui/camera/GraphicOverlay.java" target-dir="src/ui/camera/" />

        <source-file src="src/android/libs/google-play-services.jar" target-dir="libs/" />
        <source-file src="src/android/libs/android-support-v4.jar" target-dir="libs/" />
        <source-file src="src/android/libs/android-support-v7-appcompat.jar" target-dir="libs/" />
        <source-file src="src/android/libs/android-support-design.jar" target-dir="libs/" />
    </platform>

</plugin>

And this is the original Android Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="theUser.multibarcode">

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@drawable/icon"
        android:theme="@style/Theme.AppCompat"
        android:label="MultiTrackerApp">

        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode,face" />

        <activity
            android:name="theUser.multibarcode.MultiTrackerActivity"
            android:icon="@drawable/icon"
            android:label="Multi-Tracker"
            android:theme="@style/Theme.AppCompat.NoActionBar"
            android:screenOrientation="fullSensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

As soon as I press the button, the called app crashes. I can see the error in Android Studio, because my phone is connected:

03-29 13:53:27.107  10131-10131/com.henning E/﹕ appName=com.henning, acAppName=/system/bin/surfaceflinger
03-29 13:53:27.108  10131-10131/com.henning E/﹕ 0
03-29 13:53:27.374  10131-10131/com.henning E/﹕ appName=com.henning, acAppName=/system/bin/surfaceflinger
03-29 13:53:27.374  10131-10131/com.henning E/﹕ 0
03-29 13:53:46.740  10131-10131/com.henning E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.henning, PID: 10131
    java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:336)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
            at roesner.multibarcode.MultiTrackerActivity.onCreate(MultiTrackerActivity.java:70)
            at android.app.Activity.performCreate(Activity.java:5264)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
            at dalvik.system.NativeStart.main(Native Method)

Does anyone have an idea how I can solve this issue or if I have done any errors before that could cause this one?

Sufian
  • 6,405
  • 16
  • 66
  • 120
Max
  • 1
  • This seems related to your styling. See this like `java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable` in your Logcat. – Sufian Mar 29 '16 at 12:16
  • what do you mean by "see this like"? I have no problems when running the app from within Android Studio. Any idea how I could fix the styling problem? – Max Mar 29 '16 at 12:49
  • I changed the XML file to another layout. The error is gone, but now I am getting a different one: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.user/theUser.multibarcode.MultiTrackerActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0 – Max Mar 29 '16 at 13:39
  • Firstly I'm an Android dev, no experience in Cordova at all. Anyway. Your original question seems to be related to [java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable](http://stackoverflow.com/questions/22526925/java-lang-noclassdeffounderror-android-support-v7-appcompat-rstyleable). Check if the discussion there helps you. – Sufian Mar 30 '16 at 05:50

0 Answers0