1

我想在 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
4

1 回答 1

5

错误说

android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile

这意味着您在声明 com.digitalaria.gama.tile.Tile 的 xml 文件的第 7 行有错误,因此请检查该类是否可用。

在您使用 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
于 2012-07-02T11:30:34.143 回答