2017-07-29 76 views
1

我發現Neura AUTH的例子,然後創建一個活動並粘貼此代碼:的NoSuchMethodError Neura

public class NeuraActivity extends AppCompatActivity { 
private NeuraApiClient mNeuraApiClient; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_neura); 
    Builder builder = new Builder(getApplicationContext()); 
    mNeuraApiClient = builder.build(); 
    mNeuraApiClient.setAppUid("APP_UID"); 
    mNeuraApiClient.setAppSecret("APP_SECRET"); //here is my app secret, I dont want to show it 
    mNeuraApiClient.connect(); 
    auth(); 
} 

public void auth() { 
    mNeuraApiClient.authenticate(new AuthenticateCallback() { 
     @Override 
     public void onSuccess(AuthenticateData authenticateData) { 
      Log.i(getClass().getSimpleName(), "Successfully authenticate with neura. " + 
        "NeuraUserId = " + authenticateData.getNeuraUserId() + " " + 
        "AccessToken = " + authenticateData.getAccessToken()); 

      //If you're using firebase for receiving the moment, make sure to call this method. 
      //Plus, make sure you've registered your firebase server key for your project in our dev site : 
      //https://dev.theneura.com/docs/guide/android/pushnotification 
      //If you're putting this code in an activity : ACTIVITY_CONTEXT = YourActivityName.this. 
      //If you're putting this code in an fragment : ACTIVITY_CONTEXT = getActivity() 
      mNeuraApiClient.registerFirebaseToken(NeuraActivity.this, 
        FirebaseInstanceId.getInstance().getToken()); 

      ArrayList<EventDefinition> events = authenticateData.getEvents(); 
      //Subscribe to the events you wish Neura to alert you : 
      for (int i = 0; i < events.size(); i++) { 
       mNeuraApiClient.subscribeToEvent(events.get(i).getName(), 
         "com.chopikus.schoolhelperse" + events.get(i).getName(), 
         new SubscriptionRequestCallbacks() { 
          @Override 
          public void onSuccess(String eventName, Bundle bundle, String s1) { 
           Log.i(getClass().getSimpleName(), "Successfully subscribed to event " + eventName); 
          } 

          @Override 
          public void onFailure(String eventName, Bundle bundle, int i) { 
           Log.e(getClass().getSimpleName(), "Failed to subscribe to event " + eventName); 
          } 
         }); 
      } 
     } 

     @Override 
     public void onFailure(int i) { 
      Log.e(getClass().getSimpleName(), "Failed to authenticate with neura. " 
        + "Reason : " + SDKUtils.errorCodeToString(i)); 
     } 
    }); 
} 


} 

這裏是我的gradle這個依賴關係:

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 

// this line must be included to integrate with Firebase 
compile 'com.google.firebase:firebase-core:11.0.1' 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.google.firebase:firebase-auth:11.0.1' 
compile 'com.google.firebase:firebase-storage:11.0.1' 
compile 'com.google.firebase:firebase-database:11.0.1' 
compile 'com.google.firebase:firebase-messaging:11.0.1' 
compile 'org.apache.directory.studio:org.apache.commons.io:2.4' 
compile 'com.koushikdutta.ion:ion:2.+' 
compile 'com.github.barteksc:android-pdf-viewer:2.5.1' 
compile 'com.squareup.picasso:picasso:2.5.2' 
compile 'com.github.kenglxn.QRGen:android:2.2.0' 
compile 'me.dm7.barcodescanner:zxing:1.9' 
compile 'com.google.zxing:core:3.2.1' 
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.1' 
compile 'com.afollestad.material-dialogs:core:0.9.4.5' 
compile 'com.github.clans:fab:1.6.2' 
compile 'com.google.android.gms:play-services-auth:11.0.1' 
compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
compile 'com.github.chrisbanes:PhotoView:2.0.0' 
compile 'me.grantland:autofittextview:0.2.+' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
compile 'com.theneura:android-sdk:+' 
testCompile 'junit:junit:4.12' 
} 

當我開始活動,我得到錯誤:

java.lang.NoSuchMethodError: No static method zzw(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac;

請幫幫我。

+0

Neura是否依賴於特定版本的Google Auth? –

+0

cricket007,正如我從changelog知道的那樣,nuera將auth升級到10.2.0。但由於PhoneProvider我使用了11。所以我認爲第 –

回答

0

我只是說playservices-分析,基地,位置,地圖圖書館和所有正在加入這個。

+0

你甚至需要地圖嗎? –

0

在gradle這個

compile "com.google.android.gms:play-services-base:+" 
compile 'com.google.android.gms:play-services-location:+' 
compile 'com.google.android.gms:play-services-maps:+' 
+0

請不要使用plus作爲版本,問題提及地圖在哪裏? –

+0

我使用版本11.0.4而不是+每個地方和相同的錯誤 –

+0

@IgorChovpan所有其他庫使用11.0.1 –