java.lang.UnsatisfiedLinkError 当 运行 android 应用

java.lang.UnsatisfiedLinkError when running android application

我正在使用Android Studio,制作简单的应用程序。 我想使用 Andengine 和 Andengine box2d 扩展库,所以我将 jar 文件复制到 Project/apps/libs/ 并做了 File-Project Structure-app-dependencies-Green + Button - File Dependency - 添加两个 jar 文件。 代码内容非常简单:导入库并创建一个新的物理世界

    import android.annotation.TargetApi;
    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.RectF;
    import android.graphics.drawable.shapes.RectShape;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Message;
    import android.support.annotation.Nullable;
    import android.support.v7.app.AppCompatActivity;
    import android.util.DisplayMetrics;
    import android.view.View;
    import com.badlogic.gdx.math.Vector2;
    import com.badlogic.gdx.physics.box2d.Body;
    import com.badlogic.gdx.physics.box2d.BodyDef;
    import com.badlogic.gdx.physics.box2d.CircleShape;
    import com.badlogic.gdx.physics.box2d.Fixture;
    import com.badlogic.gdx.physics.box2d.FixtureDef;
    import com.badlogic.gdx.physics.box2d.PolygonShape;
    import com.badlogic.gdx.physics.box2d.World;

    import org.andengine.extension.physics.box2d.PhysicsWorld;
    import java.util.ArrayList;

public class PvPActivity extends AppCompatActivity implements View.OnClickListener{
PhysicsWorld world;
ArrayList<Body> WhiteStoneArray,BlackStoneArray;
GameView gameview;
int ScreenWidth,ScreenHeight,radius;
int UpMenuHeight,GameHeight,DownMenuHeight;
int UpMenuY,GameY,DownMenuY;
boolean playerturn=true;
Handler mHandler=new Handler(){
    public void handleMessage(Message msg){
        gameview.invalidate();
        //world.step(0.01f,1,1);
        mHandler.sendEmptyMessageDelayed(0,100);
    }
};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    //pre-settings for View and some variables
    super.onCreate(savedInstanceState);
    gameview=new GameView(this);
    setContentView(gameview);
    WhiteStoneArray=new ArrayList<Body>();
    BlackStoneArray=new ArrayList<Body>();
    DisplayMetrics disp=getApplicationContext().getResources().getDisplayMetrics();
    ScreenWidth=disp.widthPixels;
    ScreenHeight=disp.heightPixels;
    //set variables about Screen Size
    radius=ScreenHeight/20;//Set radius of stone = 5% of screen height
    UpMenuY=0;//Begin of UpMenu Y coordinate
    GameY=ScreenHeight/5;//Begin of GameView Y coordinate
    DownMenuY=ScreenHeight*9/10;//Begin of DownMenu Y coordinate
    UpMenuHeight=ScreenHeight/5;//Height of UpMenu = 20% of screen height
    GameHeight=ScreenHeight*7/10;//Height of GameMenu = 70% of screen height
    DownMenuHeight=ScreenHeight/5;//Height of DownMenu = 10% of screen height


    //set Box2D World
    world=new PhysicsWorld(new Vector2(0,-10f),true);
    mHandler.sendEmptyMessage(0);//start Handler
}
class GameView extends View {
    public GameView(Context context) {
        super(context);
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p=new Paint();
        p.setAntiAlias(true);
        canvas.drawText("Paint Test",0f,0f,p);
    }
    public void addNewStone(int x,int y){
        BodyDef StoneDef=new BodyDef();
        StoneDef.position.set(new Vector2(x,-y));
        Body StoneBody=world.createBody(StoneDef);
        if(playerturn){
            WhiteStoneArray.add(StoneBody);
            playerturn=false;
        }
        else{
            BlackStoneArray.add(StoneBody);
            playerturn=true;
        }
        CircleShape StoneShape=new CircleShape();
        StoneShape.setRadius(radius);
        FixtureDef StoneFixture=new FixtureDef();
        StoneFixture.density=1;
        StoneFixture.friction=1;
        StoneFixture.restitution=1;
        StoneFixture.shape=StoneShape;
        StoneBody.createFixture(StoneFixture);
    }
}
@Override
public void onClick(View view) {
    if(GameY<=view.getY()&&GameY+GameHeight>=view.getY()){
        //gameview.addNewStone((int)view.getX(),(int)view.getY());
    }
}
}

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile files('libs/org_andengine_extension_physics_box2d.jar')
    compile files('libs/org_andengine.jar')
}
apply plugin: 'com.android.application'

这是我 运行 这个应用程序

时的错误消息
    java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-support-annotations-25.0.0_ee7e9a33607a4b20cc7fc4a9de22e722aae9837b-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-org_andengine_extension_physics_box2d_0a0ee4336bdf5152c251673affd08f44e9819501-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-org_andengine_aa27347b199075e3e8eb7a180491e16195d84ba9-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-internal_impl-25.0.0_f6782dffbbfa20552c398cf53ac9deb2658c71ec-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-internal_impl-25.0.0_bc496c8bfa53dddde95ddc39cfb34a4fe2e39dea-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-internal_impl-25.0.0_b9082e72cbd30bc72a452a4c4514e7379a1d7184-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-internal_impl-25.0.0_9fa5df76df8f97a93d978537ed4a25cd9e8c55a8-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-internal_impl-25.0.0_05566ea662513b8bdb99b5532b5ac3e766ef24cd-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-vector-drawable-25.0.0_a5e795f5016d951f928483efae033259090a6f05-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-v4-25.0.0_24e2952335070557edc2f375decfb230cf7b5a0e-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-media-compat-25.0.0_1cea6c5351a7d50ff09f9f09de36eccfd70c73d7-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-fragment-25.0.0_dbb3c23bff1171b9e2d58b81c7c23fa2e11b3a4a-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-core-utils-25.0.0_f53d36752c5611401dc871b83261d909db44ba70-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-core-ui-25.0.0_3a815a7101840920878231e059c15ef73b846469-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-support-compat-25.0.0_d0220dcbe50daae00d9cb56a1c4446c6e55932b6-classes.dex", dex file "/data/data/es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid/files/instant-run/dex/slice-com.android.support-appcompat-v
    package es.esy.m3na71jnu5cg5e2.gs14049_bsj_mid;

有人帮忙吗?

试试这个,希望对你有帮助

Just turn off instant-run from Setting/Preferences -> Build,Execution,Deployment -> Instant Run and uncheck the first two check-boxes. This error is because of instant-run feature.

可以在这里查看我的答案。

未满足的link错误是在找不到.so文件时出现的。