简体   繁体   中英

NoSuchMethodError Neura

I found the example of auth in Neura, then created an activity and pasted this code:

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));
        }
    });
}


}

Here is my gradle dependencies:

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'
 }

And when I start activity I get the error:

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

Please help me.

Add this in your 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:+'

我刚刚添加了playservices-analytics,基础,位置,地图库,并且一切正常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM