我该如何修复java.lang.UnsatisfiedLinkError?

时间:2014-10-23 14:30:54

标签: android android-layout android-listview

大家好我正在尝试做一个扩展listActivity的新活动,因为我想做一个项目列表,但是当我用一个按钮启动它时,它给了我java.lang.UnsatisfiedLinkError。这个类和布局只是inizializated没有什么特别的..但是它给了我这个错误:/下面你可以找到我的logcat以及我的布局和我的类。谢谢。

扩展ListActivity的类:

public class AndroidListViewActivity extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);

        // storing string resources into Array
        //String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
         String[] adobe_products = {"prova","prova1","prova2"};
        // Binding resources Array to ListAdapter
        //this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));

    }
}

布局(R.layout.activity_list):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"   
    android:layout_height="match_parent" 
    android:orientation="vertical"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"  
    tools:context="com.example.findmyclients.AndroidListViewActivity">

    <FrameLayout
        android:id="@+id/custom_header_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="@drawable/header" 
        android:layout_alignParentTop="true">
    </FrameLayout>



</RelativeLayout>

logcat的:

10-23 16:23:46.296: W/dalvikvm(16222): No implementation found for native Ldalvik/system/VMRuntime;.pauseGc:(Ljava/lang/String;)I
10-23 16:23:46.301: E/ActivityThread(16222): Pause GC
10-23 16:23:46.301: E/ActivityThread(16222): java.lang.reflect.InvocationTargetException
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invokeNative(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invoke(Method.java:515)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.pauseGC(ActivityThread.java:5525)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2324)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.access$900(ActivityThread.java:175)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.os.Looper.loop(Looper.java:146)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.main(ActivityThread.java:5602)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invokeNative(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invoke(Method.java:515)
10-23 16:23:46.301: E/ActivityThread(16222):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
10-23 16:23:46.301: E/ActivityThread(16222):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
10-23 16:23:46.301: E/ActivityThread(16222):    at dalvik.system.NativeStart.main(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: dalvik.system.VMRuntime.pauseGc:(Ljava/lang/String;)I
10-23 16:23:46.301: E/ActivityThread(16222):    at dalvik.system.VMRuntime.pauseGc(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    ... 15 more

1 个答案:

答案 0 :(得分:0)

布局中的ListView可以是更好的选择,而不是使用ListActivity或ListFragment。 这就是我的意思:

这里我使用一个包含ListView的片段:

public final class FRG_List
extends Fragment
{

    private ClickListener listener;

    /* ------------------------------ Objects ------------------------------- */

    private ListView lvw = null;

    // ...

    @Override
    public final View onCreateView
    (
        final LayoutInflater li, final ViewGroup container,
        final Bundle savedInstanceState
    )
    {
        final View v = li.inflate(R.layout.frg_list, container, false);
        return v;
    }

    // ...

}

这是/res/layout/frg_list.xml(ListView):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ListView
        android:id="@+id/lvwResults"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:layout_margin="4dp"
    />
    <TextView
        android:id="@+id/txtEmpty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textColor="@color/black_tsp_50"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold"
        android:shadowColor="@color/white_tsp_50"
        android:shadowRadius="1"
        android:shadowDx="1"
        android:shadowDy="1"
        android:visibility="gone"
        android:clickable="true"
        android:onClick="clickHandler"
    />
</RelativeLayout>

我使用TextView显示&#34;没有找到数据&#34;数据库没有结果时的消息 我在代码中管理它(我将其设置为可见或消失)。

但是你可以跳过它,如果你不需要它(在这种情况下你可以摆脱RelativeLayout容器并将xml命名空间分配给ListView本身,以平整你的布局 - 这对于性能)。