我正在尝试制作.so文件,但它显示错误

时间:2014-02-28 07:27:24

标签: android sqlite android-ndk java-native-interface

我正在尝试制作.so文件,但它会出现以下错误  ndroid-ndk-r9\ndk-build.cmd all make: Nothing to be done for全部”。  `

在jni文件夹中我有所有这些文件

intarray.c
intarray.h
jni_setup.h
sqlite_extension_example.c
sqlite3_wrap_manual.c
sqlite3_wrap_manual.h
sqlite3.c
sqlite3.h
sqlite4java-android.cpp
Android.mk

直到现在我能够在obj文件夹下生成.a文件,即libsqlite3.a

以下是代码

package com.example.sqlite4;

import java.io.File;
import java.util.ArrayList;

import com.almworks.sqlite4java.SQLiteConnection;
import com.almworks.sqlite4java.SQLiteStatement;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity {
ArrayList<String> orders = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    try {
        System.loadLibrary("sqlite4java-android");
        SQLiteConnection db = new SQLiteConnection(new File("/storage/sdcard1/sk.db"));
        db.open(true);
        SQLiteStatement st = db.prepare("select C0,C1,C2,C3,C4 from T0 where C0= ?");
        try {

            String minimumQuantity = "'2907'";
            st.bind(1, minimumQuantity);
            while (st.step()) {
                orders.add(st.columnString(0));
                orders.add(st.columnString(1));
                orders.add(st.columnString(2));
                orders.add(st.columnString(3));
            }
        } finally {
            st.dispose();
        }
        db.dispose();
    } catch (Exception e) 
    {
        e.printStackTrace();
    }

    Toast.makeText(getBaseContext(),orders.toString() , Toast.LENGTH_LONG).show();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
}

这是日志

02-28 12:51:11.846: E/AndroidRuntime(8357): FATAL EXCEPTION: main
02-28 12:51:11.846: E/AndroidRuntime(8357): java.lang.UnsatisfiedLinkError: Couldn't load sqlite4java-android: findLibrary returned null
02-28 12:51:11.846: E/AndroidRuntime(8357):     at java.lang.Runtime.loadLibrary(Runtime.java:365)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at java.lang.System.loadLibrary(System.java:535)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at com.example.sqlite4.MainActivity.onCreate(MainActivity.java:22)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.Activity.performCreate(Activity.java:5020)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.ActivityThread.access$600(ActivityThread.java:149)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.os.Looper.loop(Looper.java:153)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at android.app.ActivityThread.main(ActivityThread.java:4987)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at java.lang.reflect.Method.invokeNative(Native Method)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at java.lang.reflect.Method.invoke(Method.java:511)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-28 12:51:11.846: E/AndroidRuntime(8357):     at dalvik.system.NativeStart.main(Native Method)

我的Android.mk文件

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

# If using SEE, uncomment the following:
# LOCAL_CFLAGS += -DSQLITE_HAS_CODEC

LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA
LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL
LOCAL_CFLAGS += -U__APPLE__
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-int-to-pointer-cast
LOCAL_CFLAGS += -Wno-maybe-uninitialized -Wno-parentheses
LOCAL_CPPFLAGS += -Wno-conversion-null


ifeq ($(TARGET_ARCH), arm)
LOCAL_CFLAGS += -DPACKED="__attribute__ ((packed))"
else
LOCAL_CFLAGS += -DPACKED=""
endif

LOCAL_SRC_FILES:=sqlite3.c
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/native/
LOCAL_MODULE:= sqlite4java-android
LOCAL_LDLIBS += -ldl -llog

include $(BUILD_SHARED_LIBRARY)

请帮帮我

0 个答案:

没有答案