RealmLog native Implementation not found

泄露秘密 提交于 2019-12-06 08:42:48

问题


I am trying to use Realm Mobile Database, but i have some issues :

I installed a Realm Object Server, and i try to create a use with an activity.

Here my RegisterActivity

public class RegisterActivity extends AppCompatActivity implements SyncUser.Callback {

private AutoCompleteTextView usernameView;
private EditText passwordView;
private EditText passwordConfirmationView;
private View progressView;
private View registerFormView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
    usernameView = (AutoCompleteTextView) findViewById(R.id.username);
    passwordView = (EditText) findViewById(R.id.password);
    passwordConfirmationView = (EditText) findViewById(R.id.password_confirmation);
    passwordConfirmationView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.register || id == EditorInfo.IME_NULL) {
                attemptRegister();
                return true;
            }
            return false;
        }
    });


    final Button mailRegisterButton = (Button) findViewById(R.id.email_register_button);
    mailRegisterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptRegister();
        }
    });

    registerFormView = findViewById(R.id.register_form);
    progressView = findViewById(R.id.register_progress);
}

private void attemptRegister() {
    usernameView.setError(null);
    passwordView.setError(null);
    passwordConfirmationView.setError(null);

    final String username = usernameView.getText().toString();
    final String password = passwordView.getText().toString();
    final String passwordConfirmation = passwordConfirmationView.getText().toString();

    boolean cancel = false;
    View focusView = null;


    if (isEmpty(username)) {
        usernameView.setError(getString(R.string.error_field_required));
        focusView = usernameView;
        cancel = true;
    }

    if (isEmpty(password)) {
        passwordView.setError(getString(R.string.error_field_required));
        focusView = passwordView;
        cancel = true;
    }

    if (isEmpty(passwordConfirmation)) {
        passwordConfirmationView.setError(getString(R.string.error_field_required));
        focusView = passwordConfirmationView;
        cancel = true;
    }

    if (!password.equals(passwordConfirmation)) {
        passwordConfirmationView.setError(getString(R.string.error_incorrect_password));
        focusView = passwordConfirmationView;
        cancel = true;
    }
    if (cancel) {
        focusView.requestFocus();
    } else {
        showProgress(true);
        SyncUser.loginAsync(SyncCredentials.usernamePassword(username, password, true), AUTH_URL, new SyncUser.Callback() {
            @Override
            public void onSuccess(SyncUser user) {
                registrationComplete(user);
            }

            @Override
            public void onError(ObjectServerError error) {
                showProgress(false);
                String errorMsg;
                switch (error.getErrorCode()) {
                    case EXISTING_ACCOUNT:
                        errorMsg = "Account already exists";
                        break;
                    default:
                        errorMsg = error.toString();
                }

                RealmLog.info(errorMsg);
                Toast.makeText(RegisterActivity.this, errorMsg, Toast.LENGTH_LONG).show();
            }
        });
    }
}

private void registrationComplete(SyncUser user) {
    UserManager.setActiveUser(user);
    Intent intent = new Intent(this, LoginActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
}

private void showProgress(final boolean show) {
    final int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

    registerFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    registerFormView.animate().setDuration(shortAnimTime).alpha(
            show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            registerFormView.setVisibility(show ? View.GONE : View.VISIBLE);
        }
    });

    progressView.setVisibility(show ? View.VISIBLE : View.GONE);
    progressView.animate().setDuration(shortAnimTime).alpha(
            show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            progressView.setVisibility(show ? View.VISIBLE : View.GONE);
        }
    });
}

@Override
public void onSuccess(SyncUser user) {
    registrationComplete(user);
}

@Override
public void onError(ObjectServerError error) {
    String errorMsg;
    switch (error.getErrorCode()) {
        case EXISTING_ACCOUNT:
            errorMsg = "Account already exists";
            break;
        default:
            errorMsg = error.toString();
    }
    RealmLog.info(errorMsg);
    Toast.makeText(RegisterActivity.this, errorMsg, Toast.LENGTH_LONG).show();
}

}

But when i click on validate or on the button on my view, it crash with the stack

java.lang.UnsatisfiedLinkError: No implementation found for void io.realm.log.RealmLog.nativeLog(int, java.lang.String, java.lang.Throwable, java.lang.String) (tried Java_io_realm_log_RealmLog_nativeLog and Java_io_realm_log_RealmLog_nativeLog__ILjava_lang_String_2Ljava_lang_Throwable_2Ljava_lang_String_2)
                                                                          at io.realm.log.RealmLog.nativeLog(Native Method)
                                                                          at io.realm.log.RealmLog.log(RealmLog.java:371)
                                                                          at io.realm.log.RealmLog.info(RealmLog.java:263)
                                                                          at io.realm.log.RealmLog.info(RealmLog.java:252)
                                                                          at com.activity.user.RegisterActivity$3.onError(RegisterActivity.java:126)
                                                                          at io.realm.SyncUser$1$1.run(SyncUser.java:206)
                                                                          at android.os.Handler.handleCallback(Handler.java:751)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                          at android.os.Looper.loop(Looper.java:154)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

or this when i comment all RealmLog line

No implementation found for void io.realm.log.RealmLog.nativeLog(int, java.lang.String, java.lang.Throwable, java.lang.String) (tried Java_io_realm_log_RealmLog_nativeLog and Java_io_realm_log_RealmLog_nativeLog__ILjava_lang_String_2Ljava_lang_Throwable_2Ljava_lang_String_2

Edit : Here the gradle file :

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "********"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "0.0.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "OBJECT_SERVER_IP", "\"XXXX\""
        }
        debug {
            // This will automatically detect the IP address of the machine building RealmTasks.
            // It is assumed that this machine is also running the Object Server.
            // If not, replace 'host' with the IP of the machine hosting the server.
            buildConfigField "String", "OBJECT_SERVER_IP", "\"XXXX\""
        }
    }
    dataBinding {
        enabled = true;
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}
realm {
    syncEnabled = true
}
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 project(path: ':androidhttprequestlibrairy')
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
    compile 'org.jsoup:jsoup:1.7.3'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    compile 'com.jakewharton:butterknife:8.4.0'
    compile 'org.apache.commons:commons-collections4:4.1'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'io.realm:android-adapters:1.4.0'
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'
}

回答1:


You need to call init first

Realm.init()


来源:https://stackoverflow.com/questions/41472178/realmlog-native-implementation-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!