我想在Android中使用Gama组件使我们的应用程序运行良好。我已经下载了Gama jar甚至它抛出错误。我已经关注了以下链接http://developer.digitalaria.com/devguide/gama/en/gama/tile_android.php。
爪哇
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import com.digitalaria.gama.tile.Tile;
public class GamaAndroidActivity extends Activity {
Button button;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.digitalaria.gama.tile.Tile
android:id="@+id/tile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
的错误
07-02 16:52:02.623: E/AndroidRuntime(1849): FATAL EXCEPTION: main
07-02 16:52:02.623: E/AndroidRuntime(1849): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.gama/com.test.gama.GamaAndroidActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.os.Looper.loop(Looper.java:123)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.reflect.Method.invoke(Method.java:521)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-02 16:52:02.623: E/AndroidRuntime(1849): at dalvik.system.NativeStart.main(Native Method)
07-02 16:52:02.623: E/AndroidRuntime(1849): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.Activity.setContentView(Activity.java:1647)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.test.gama.GamaAndroidActivity.onCreate(GamaAndroidActivity.java:15)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-02 16:52:02.623: E/AndroidRuntime(1849): ... 11 more
07-02 16:52:02.623: E/AndroidRuntime(1849): Caused by: java.lang.ClassNotFoundException: com.digitalaria.gama.tile.Tile in loader dalvik.system.PathClassLoader[/data/app/com.test.gama-1.apk]
07-02 16:52:02.623: E/AndroidRuntime(1849): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-02 16:52:02.623: E/AndroidRuntime(1849): ... 20 more
答案 0 :(得分:5)
错误说
android.view.InflateException:二进制XML文件行#7:错误 膨胀类com.digitalaria.gama.tile.Tile
这意味着您在声明的xml文件中的第7行上有错误 com.digitalaria.gama.tile.Tile所以检查该类是否可用。
在您使用xml文件的类中:
import com.digitalaria.gama.tile.Tile;
编辑:
要添加Gama库,请将其从javaBuildpath中删除,然后执行此操作:
1. Create a new folder, libs, in your Eclipse/Android project.
2. Right-click libs and choose Import -> General -> File System, then
Next, Browse in the filesystem to find the library's parent
directory and add your GAMA jar.
3. Right-click on your project, choose Build Path -> Configure Build
Path, then click the Libraries tab, then Add JARs..., navigate to
your new JAR in the libs directory and add it.
4. Clean the project