在Android模拟器中单击它后,我的应用程序将无法运行

时间:2015-11-10 16:15:07

标签: java android constructor android-emulator classnotfoundexception

我需要一个帮助,我想我在编译我的应用程序时犯了一个错误,因为我无法在Android模拟器上打开它它说“不幸的是MyApp已停止”

App class

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.c2call.sdk.pub.affiliate.AffiliateCredentials;
import com.c2call.sdk.pub.core.C2CallSdk;

public class App extends Application
{
    @Override
    public void onCreate()
    {
        super.onCreate();
/*
The affiliate ID and Secret from the C2Call SDK DevArea
Note: In a custom App you will have to change these to your own credentials
*/
        String affid = "Affiliateid";
        String secret = "Secretid";
        final AffiliateCredentials credentials = new AffiliateCredentials(affid,
                getPackageName(),
                secret);
/*
Initialise the C2CallSdk instance. This must be called
before using any C2Call functionality
*/
        C2CallSdk.instance().init((Application) getApplicationContext(), credentials);
/*
Set a custom StartControl and override the #openMain() method.
This method will be called from the Login controller after a successful
login. In this Demo we simply open the friend list of the user.
*/
        C2CallSdk.instance().setStartControl(new StartControl());
    }
    @Override
    protected void attachBaseContext(Context base)
    {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}



apply plugin: 'com.android.application'



task copyLibs(type: Copy){
    description 'Copy lib-c2callsdk.aar to libs'
    from '../../lib-c2callsdk/app/build/outputs/aar'
    into 'libs'
    include('*.aar')
}


preBuild.dependsOn copyLibs


android {
    compileSdkVersion "Google Inc.:Google APIs:23"
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.chatibo.chatibo"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0.0"
        multiDexEnabled = true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }


    lintOptions {
        checkReleaseBuilds false
    }



}

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile(name: 'lib-c2callsdk', ext: 'aar')
    compile 'com.android.support:support-v13:+'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
}

这是运行完成后的Gradle Build输出消息,如果显示错误,您可以检查它:

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
:app:copyLibs UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV132310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:app:prepareLibC2callsdkLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:packageAllDebugClassesForMultiDex
:app:shrinkDebugMultiDexComponents
:app:createDebugMainDexClassList
:app:dexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$5) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$6) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.services.s3.model.a.d) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
Information:BUILD SUCCESSFUL
Information:Total time: 5 mins 29.016 secs
Information:0 errors
Information:0 warnings
Information:See complete output in console

logcat

11-11 05:47:46.982 2602-2602/? I/art: Not late-enabling -Xcheck:jni (already on)
11-11 05:47:46.983 2602-2602/? I/art: Late-enabling JIT
11-11 05:47:47.030 2602-2602/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
11-11 05:47:47.237 2602-2602/? D/AndroidRuntime: Shutting down VM
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime: FATAL EXCEPTION: main
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime: Process: com.chatibo.chatibo, PID: 2602
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.chatibo.chatibo.App: java.lang.ClassNotFoundException: Didn't find class "com.chatibo.chatibo.App" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.chatibo.chatibo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.chatibo.chatibo-1/lib/x86, /data/app/com.chatibo.chatibo-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap1(ActivityThread.java)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.chatibo.chatibo.App" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.chatibo.chatibo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.chatibo.chatibo-1/lib/x86, /data/app/com.chatibo.chatibo-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.Instrumentation.newApplication(Instrumentation.java:981)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap1(ActivityThread.java) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime: 	Suppressed: java.lang.ClassNotFoundException: com.chatibo.chatibo.App
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.Class.classForName(Native Method)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:     		... 12 more
11-11 05:47:47.237 2602-2602/? E/AndroidRuntime:  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
11-11 05:47:50.888 2602-2602/? I/Process: Sending signal. PID: 2602 SIG: 9

任何帮助将不胜感激。 感谢

2 个答案:

答案 0 :(得分:0)

7520-7520 /? E / AndroidRuntime:致命异常:主要 11-10 15:52:34.577 7520-7520 /? E / AndroidRuntime:进程:com.chatibo.chatibo,PID:7520 11-10 15:52:34.577 7520-7520 /? E / AndroidRuntime:java.lang.RuntimeException:无法实例化应用程序com.chatibo.chatibo.App:java.lang.ClassNotFoundException:路径上没有找到类“com.chatibo.chatibo.App”:DexPathList [[zip文件] “/system/framework/com.google.android.maps.jar”,zip文件“/data/app/com.chatibo.chatibo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.chatibo .chatibo-1 / lib / x86,/ data / app / com.chatibo.chatibo-1 / base.apk!/ lib / x86,/ vendor / lib,/ system / lib]]

日志文件说明:未在路径上找到“com.chatibo.chatibo.App”类。听起来有一个文件路径与您需要的不匹配。检查所有路径以查明它们是否匹配你需要什么。

答案 1 :(得分:0)

基于发布的错误:

required: Application,AffiliateCredentials
found: Context,String,AffiliateCredentials

尝试将init()调用更改为:

C2CallSdk.instance().init((Application) getApplicationContext(), credentials);

而不是

C2CallSdk.instance().init(
                getApplicationContext(),
                getPackageName(),
                credentials);