android 4.1.2的java.lang.ClassNotFoundException

时间:2017-01-08 09:59:58

标签: java android

我已经针对Android 4.0及更高版本制作了GPS定位项目。它在Android棒棒糖及以上工作正常,但我希望它在Android 4.1.2上运行。我尝试了很多解决方案,但对我来说没什么用。 I tried solution from this link  在这个应用程序中,我只使用片段,导航栏,谷歌api的地图,位置,距离计算器,短信API,邮件功能。我还在其中制作了自定义进度对话框。

FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
      at android.app.ActivityThread.installProvider(ActivityThread.java:4692)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4319)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4261)
      at android.app.ActivityThread.access$1400(ActivityThread.java:143)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:4950)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
      at android.app.ActivityThread.installProvider(ActivityThread.java:4677)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4319) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4261) 
      at android.app.ActivityThread.access$1400(ActivityThread.java:143) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301) 
      at android.os.Handler.dispatchMessage(Handler.java:99) 
      at android.os.Looper.loop(Looper.java:137) 
      at android.app.ActivityThread.main(ActivityThread.java:4950) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:511) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771) 
      at dalvik.system.NativeStart.main(Native Method) 

我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gmaker.glocator">
    <permission
        android:name="com.gmakerorganisation.glocator.package.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.gmakerorganisation.glocator.package.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".activity.Splash"
            android:theme="@style/Splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".activity.MapsActivity" />
        <activity android:name=".activity.SignUp" />
        <activity android:name=".activity.SignIn" />
        <activity android:name=".activity.Forget" />
        <activity
            android:name=".activity.MainMenu"
            android:theme="@style/navigation" />
        <activity android:name=".activity.Mailer" />
    </application>

</manifest>

的build.gradle

 apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion '25'
        defaultConfig {
            applicationId "com.gmaker.glocator"
            minSdkVersion 9
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile files('libs/activation.jar')
        compile files('libs/additionnal.jar')
        compile files('libs/mail.jar')
        compile project(':catloadinglibrary')
        compile 'com.android.support:appcompat-v7:25.1.0'
        compile 'com.mcxiaoke.volley:library-aar:1.0.0'
        compile 'cz.msebera.android:httpclient:4.4.1.1'
        compile 'com.android.support:design:25.1.0'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.google.android.gms:play-services:10.0.1'
        compile 'com.google.maps.android:android-maps-utils:0.3.+'
        compile 'com.android.support:support-v4:25.1.0'
        compile 'com.google.android.gms:play-services-ads:10.0.1'
        testCompile 'junit:junit:4.12'
    }

我已经安装了Google Play服务&#39;修订版30 还添加了应用程序ID 同时覆盖attachBaseContext,MultiDex.install(this); 但没有任何作用

1 个答案:

答案 0 :(得分:0)

有同样的问题,我已完成如下

使用最新的Google Play服务但无效。对我来说,这个程序正在起作用:1。更新了我的Application类:

  public class App extends Application {
  @Override
  protected void attachBaseContext(Context base) {
  super.attachBaseContext(base);
  MultiDex.install(this);
  }
  }

更新了build.gradle文件:

  defaultConfig { ...

  multiDexEnabled true

  }

包含依赖项:

  dependencies {
  compile 'com.android.support:multidex:1.0.0'
  }

问题现已修复