Android的 - 无法访问扩展应用程序类时landroid /应用/仪器仪表 [英] Android - not accessible to landroid/app/instrumentation when extending application class

查看:119
本文介绍了Android的 - 无法访问扩展应用程序类时landroid /应用/仪器仪表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林慢慢努力学习android的,但香港专业教育学院碰到挂机,我不能完全弄清楚。我试图用一些全局变量工作。我已经扩展了应用程序类。我已经添加了什么,我认为是正确的清单(类的名字是财富紧缩):

Im slowly trying to learn android but Ive run into a hang up that I can't quite figure out. I'm trying to work with some global variables. I have extended the Application class. I have added what I think is correct to the manifest (the name of the class is Fortune Crunch):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.marctremblay.test.fortunecrunch"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" android:debuggable="true"
        android:name=".FortuneCrunch">
        <activity
            android:name=".FortuneCrunchActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity>
</application>

那么这就是我在我FortuneCrunchActivity.java文件:

Then this is what I have in my FortuneCrunchActivity.java file:

package com.marctremblay.test.fortunecrunch;
import android.app.Activity;
import android.app.Application;


import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

class FortuneCrunch extends Application{

FortuneCrunch()
{   
}


}


class FortuneCrunchActivity extends Activity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

}

我已经基本取消了所有我的code,试图让这个类公正的工作,以确保该问题与心不是别的。如果我从清单中删除了android ::名字我不再得到错误。

I have basically removed all my code to try and get this class working just to be sure the issue isnt with anything else. If I remove the android::name from my manifest I no longer get the error.

下面是确切的错误

的newInstance失败:LCOM / marctremblay /测试/ fortunecrunch / FortuneCrunch;不访问Landroid /应用/仪器仪表;

newInstance failed: Lcom/marctremblay/test/fortunecrunch/FortuneCrunch; not accessible to Landroid/app/Instrumentation;

我难倒。我有这样的设置,就像我在许多例子已经看到了。想法将不胜AP preciated!谢谢你。

I am stumped. I have this setup just as I have seen it in many examples. Ideas would be greatly appreciated! Thanks.

推荐答案

尝试把 FortuneCrunch 类在它自己的文件, FortuneCrunch.java ,这个里面:

Try putting the FortuneCrunch class in its own file, FortuneCrunch.java, with this inside:

package com.marctremblay.test.fortunecrunch;
import android.app.Application;

public class FortuneCrunch extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    // Initialize your variables here
  }
}

这篇关于Android的 - 无法访问扩展应用程序类时landroid /应用/仪器仪表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆