【问题标题】:NoSuchMethodError NeuraNoSuchMethodError 神经元
【发布时间】:2017-07-29 13:28:11
【问题描述】:

我在Neura中找到了auth的例子,然后创建了一个activity并粘贴了这段代码:

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: 没有静态方法 zzw(Ljava/lang/Object;)Ljava/lang/Object;在 Lcom/google/android/gms/common/internal/zzac 类中;

请帮帮我。

【问题讨论】:

  • Neura 是否依赖于特定版本的 Google Auth?
  • cricket007,据我所知,nuera 将身份验证升级到了 10.2.0。但我使用 11 因为 PhoneProvider。所以我认为没有。

标签: android firebase neura


【解决方案1】:

在你的 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:+'

【讨论】:

  • 请不要使用plus作为版本,问题在哪里提到了地图?
  • 我使用的是 11.0.4 版本而不是 +,每个地方都出现同样的错误
  • @IgorChovpan 您所有其他库都使用 11.0.1
  • 是的,请使用相同的方式使它们同步
  • 我之前把所有的库版本都改成了11.0.4。
【解决方案2】:

我刚刚添加了 playservices-analytics、base、位置、地图库,一切正常。

【讨论】:

  • 你还需要地图吗?
猜你喜欢
  • 2016-09-02
  • 1970-01-01
  • 2017-09-11
  • 2016-12-23
  • 1970-01-01
  • 2017-05-21
  • 2012-10-18
  • 2016-09-08
  • 1970-01-01
相关资源
最近更新 更多