2017-09-02 14 views
0

我在我的應用程序中配置了谷歌API登錄API,並且我在獲取illegalAccessError時啓動了應用程序和Looper.prepare()錯誤日誌當我點擊谷歌的登錄按鈕工作線程上的任務異常:java.lang.IllegalAccessError AND不能在線程內創建沒有調用Looper.prepare()的處理程序

09-03 02:34:12.615 13855-14016/com.xyz I/OpenGLRenderer: Initialized EGL, version 1.4 
09-03 02:34:13.027 13855-13944/com.xyz D/FA: Connected to remote service 
09-03 02:34:13.027 13855-13944/com.xyz V/FA: Processing queued up service tasks: 1 
09-03 02:34:13.034 13855-13944/com.xyz E/FA: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.xyz-2/split_lib_dependencies_apk.apk:classes17.dex): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source) 
09-03 02:34:18.028 13855-13944/com.xyz V/FA: Inactivity, disconnecting from AppMeasurementService 
09-03 02:34:33.162 13855-13944/com.xyz V/FA: Activity paused, time: 362334438 
09-03 02:34:33.165 13855-15188/com.xyz E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare() 
09-03 02:34:33.165 13855-15188/com.xyz D/AppTracker: App Event: stop 
09-03 02:34:33.196 13855-13855/com.xyz V/FA: onActivityCreated 
09-03 02:34:33.220 13855-13944/com.xyz V/FA: Activity resumed, time: 362334496 
09-03 02:34:33.221 13855-15190/com.xyz E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare() 
09-03 02:34:33.221 13855-15190/com.xyz D/AppTracker: App Event: start 
09-03 02:34:33.296 13855-13944/com.xyz V/FA: Activity paused, time: 362334572 
09-03 02:34:33.297 13855-15191/com.xyz E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare() 
09-03 02:34:33.298 13855-15191/com.xyz D/AppTracker: App Event: stop 
09-03 02:34:34.298 13855-13944/com.xyz D/FA: Application backgrounded. Logging engagement 
09-03 02:34:34.304 13855-13944/com.xyz I/FA: Tag Manager is not found and thus will not be used 
09-03 02:34:34.317 13855-13944/com.xyz D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=20742}] 
09-03 02:34:34.319 13855-13944/com.xyz V/FA: Using measurement service 
09-03 02:34:34.319 13855-13944/com.xyz V/FA: Connecting to remote service 
09-03 02:34:34.328 13855-13944/com.xyz D/FA: Connected to remote service 
09-03 02:34:34.328 13855-13944/com.xyz V/FA: Processing queued up service tasks: 1 
09-03 02:34:34.332 13855-13944/com.xyz E/FA: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.xyz-2/split_lib_dependencies_apk.apk:classes17.dex): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source) 
09-03 02:34:39.339 13855-13855/com.xyz D/LoginActivity: handleSignInResult:false 
09-03 02:34:39.340 13855-13944/com.xyz V/FA: Activity resumed, time: 362340616 
09-03 02:34:39.341 13855-15331/com.xyz E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare() 
09-03 02:34:39.341 13855-15331/com.xyz D/AppTracker: App Event: start 
09-03 02:34:39.367 13855-13944/com.xyz V/FA: Inactivity, disconnecting from AppMeasurementService 
09-03 02:34:49.054 13855-13944/com.xyz V/FA: Activity paused, time: 362349528 
09-03 02:34:49.057 13855-15634/com.xyz E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare() 
09-03 02:34:49.057 13855-15634/com.xyz D/AppTracker: App Event: stop 
09-03 02:34:49.093 13855-13855/com.xyz D/FirebaseApp: Notifying background state change listeners. 
09-03 02:34:50.089 13855-13944/com.xyz D/FA: Application backgrounded. Logging engagement 
09-03 02:34:50.092 13855-13944/com.xyz D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=8912}] 
09-03 02:34:50.092 13855-13944/com.xyz V/FA: Using measurement service 
09-03 02:34:50.092 13855-13944/com.xyz V/FA: Connecting to remote service 
09-03 02:34:50.111 13855-13944/com.xyz D/FA: Connected to remote service 
09-03 02:34:50.111 13855-13944/com.xyz V/FA: Processing queued up service tasks: 1 
09-03 02:34:50.116 13855-13944/com.xyz E/FA: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.xyz-2/split_lib_dependencies_apk.apk:classes17.dex): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source) 
09-03 02:34:55.153 13855-13944/com.xyz V/FA: Inactivity, disconnecting from AppMeasurementService 

這是我build.grade(項目級別)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 
     classpath 'com.google.gms:google-services:3.0.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

build.grade(應用層)

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.0" 
    defaultConfig { 
     applicationId "com.xyz" 
     minSdkVersion 15 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     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']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.google.android.gms:play-services-auth:9.0.0' 
    testCompile 'junit:junit:4.12' 
} 

這是我的登錄活動

public class LoginActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener { 

    private static final String TAG = "LoginActivity"; 
    private static final int RC_SIGN_IN = 9001; 


    private GoogleApiClient mGoogleApiClient; 
    private TextView mStatusTextView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.login_activity); 
     loadFontsOnStartUp(); 

     GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
       .requestEmail().build(); 
     mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
       .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions).build(); 

     findViewById(R.id.google_login).setOnClickListener((View.OnClickListener) this); 

     mStatusTextView = (TextView) findViewById(R.id.testViewForLoginGoogle); 
    } 

    /** 
    * Adding custom font "berkshireswash" to the app title 
    * Adding custom font "Lato-Light" to all text on login screen 
    */ 
    public void loadFontsOnStartUp() { 

     Typeface customFontNunitoRegular = Typeface.createFromAsset(getAssets(), "fonts/Nunito-Regular.ttf"); 
     Typeface customFontBerkshire = Typeface.createFromAsset(getAssets(), "fonts/berkshireswash-regular.ttf"); 

     TextView appName = (TextView) findViewById(R.id.app_name); 
     appName.setTypeface(customFontBerkshire); 

     Button fbLogin = (Button) findViewById(R.id.facebook_login); 
     fbLogin.setTypeface(customFontNunitoRegular); 

     Button googleLogin = (Button) findViewById(R.id.google_login); 
     googleLogin.setTypeface(customFontNunitoRegular); 

     Button loginButton = (Button) findViewById(R.id.login_button); 
     loginButton.setTypeface(customFontNunitoRegular); 

     TextView forgotPasswordTextView = (TextView) findViewById(R.id.forgot_password); 
     forgotPasswordTextView.setTypeface(customFontNunitoRegular); 

     TextView signUpTextView = (TextView) findViewById(R.id.sign_up); 
     signUpTextView.setTypeface(customFontNunitoRegular); 

     TextView termsConditionsTextView = (TextView) findViewById(R.id.terms_and_conditons); 
     termsConditionsTextView.setTypeface(customFontNunitoRegular); 
    } 

    @Override 
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 
     Log.d(TAG, "onConnectionFailed:" + connectionResult); 
    } 

    @Override 
    public void onClick(View v) { 
     switch (v.getId()) { 
      case R.id.google_login: 
       signIn(); 
       break; 
     } 
    } 

    private void signIn() { 
     Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); 
     startActivityForResult(signInIntent, RC_SIGN_IN); 
    } 

    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 

     // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); 
     if (requestCode == RC_SIGN_IN) { 
      GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); 
      handleSignInResult(result); 
     } 
    } 

    private void handleSignInResult(GoogleSignInResult result) { 
     Log.d(TAG, "handleSignInResult:" + result.isSuccess()); 
     if (result.isSuccess()) { 
      // Signed in successfully, show authenticated UI. 
      GoogleSignInAccount acct = result.getSignInAccount(); 
      mStatusTextView.setText(getString(R.string.tempSignInGoogleTestString, acct.getEmail())); 
      updateUI(true); 
     } else { 
      // Signed out, show unauthenticated UI. 
      updateUI(false); 
     } 
    } 

    private void updateUI(boolean signedIn) { 
     if (signedIn) { 
      findViewById(R.id.login_button).setVisibility(View.GONE); 
     } 
    } 
} 

我真的不知道發生了什麼在這裏。它之前工作正常,然後我將Android sdk版本更改爲25,因爲我添加了Facebook sdk,並且它不受版本26的支持。它停止工作,因此我將所有內容都回滾到了工作時間,但它沒有打開現在。任何想法最新發生在這裏?

回答

1

不能上方25.0.0爲每the release notes與支持庫使用com.google.android.gms:play-services-auth:9.0.0

ContextCompat構造已經取得了保護。這個類不應該公開實例化,但可以通過針對較新API級別的支持庫進行擴展。

9.0.0沒有考慮到這個限制,造成您遇到的錯誤。您必須將您的play-services-auth依賴項更新爲更新版本。最新的,也是唯一一個與定位API 26兼容的是11.2.0

+0

我這樣做,但它說:未能解決com.google.android.gms:play-services-auth:11.2.0 –

+1

您是否閱讀了關於在11.2中使用'maven.google.com'庫的說明.0發行說明我鏈接了? – ianhanniballake

相關問題