我是一名在Mac上工作的初学者。任何有关此问题的帮助将非常感激。我的应用源代码是在Buzztouch中创建的。我已将其导入Eclipse。我已经设置了SDK。我成功运行了Hello,World应用程序。我尝试多次更改目标名称/ API级别。我已经尝试卸载并重新安装Eclipse和Android SDK Manager,并删除并重新安装了应用程序文件。
我的目标只是测试我的应用程序并将其打包以提交到应用程序商店。
当我尝试在模拟器上启动应用程序时,我得到以下结果(应用程序标题已被APPNAME替换为隐私,标题本身已正确格式化):
ON LOGCAT
04-19 18:44:25.187: E/AndroidRuntime(563): FATAL EXCEPTION: main
04-19 18:44:25.187: E/AndroidRuntime(563): java.lang.RuntimeException: Unable to resume activity {com.APPNAME/com.APPNAME.BT_screen_splash}: java.lang.NumberFormatException: Invalid int: "2.5"
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.os.Looper.loop(Looper.java:137)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.reflect.Method.invokeNative(Native Method)
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.reflect.Method.invoke(Method.java:511)
04-19 18:44:25.187: E/AndroidRuntime(563): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-19 18:44:25.187: E/AndroidRuntime(563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-19 18:44:25.187: E/AndroidRuntime(563): at dalvik.system.NativeStart.main(Native Method)
04-19 18:44:25.187: E/AndroidRuntime(563): Caused by: java.lang.NumberFormatException: Invalid int: "2.5"
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.Integer.invalidInt(Integer.java:138)
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.Integer.parse(Integer.java:375)
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.Integer.parseInt(Integer.java:366)
04-19 18:44:25.187: E/AndroidRuntime(563): at java.lang.Integer.parseInt(Integer.java:332)
04-19 18:44:25.187: E/AndroidRuntime(563): at com.APPNAME.BT_screen_splash.onResume(BT_screen_splash.java:104)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.Activity.performResume(Activity.java:4539)
04-19 18:44:25.187: E/AndroidRuntime(563): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
04-19 18:44:25.187: E/AndroidRuntime(563): ... 12 more
ON CONSOLE
[2012-04-19 18:51:57 - APP NAME] Android Launch!
[2012-04-19 18:51:57 - APP NAME] adb is running normally.
[2012-04-19 18:51:57 - APP NAME] Performing com.APPNAME.BT_activity_root activity launch
[2012-04-19 18:51:57 - APP NAME] Automatic Target Mode: launching new emulator with compatible AVD 'APPNAME'
[2012-04-19 18:51:57 - APP NAME] Launching a new emulator with Virtual Device 'APPNAME'
[2012-04-19 18:52:09 - Emulator] 2012-04-19 18:52:09.489 emulator-arm[3242:80b] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2012-04-19 18:52:09 - Emulator] emulator: emulator window was out of view and was recentered
[2012-04-19 18:52:09 - Emulator]
[2012-04-19 18:52:09 - APP NAME] New emulator found: emulator-5554
[2012-04-19 18:52:09 - APP NAME] Waiting for HOME ('android.process.acore') to be launched...
[2012-04-19 18:53:07 - APP NAME] HOME is up on device 'emulator-5554'
[2012-04-19 18:53:07 - APP NAME] Uploading APP NAME.apk onto device 'emulator-5554'
[2012-04-19 18:53:09 - APP NAME] Installing APP NAME.apk...
[2012-04-19 18:54:10 - APP NAME] Success!
[2012-04-19 18:54:10 - APP NAME] Starting activity com.APPNAME.BT_activity_root on device emulator-5554
[2012-04-19 18:54:12 - APP NAME] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.APPNAME/.BT_activity_root }
关闭EMULATOR
出现一个弹出窗口,显示“不幸的是,[应用程序名称]已停止。”
代码:BT_screen_splash.java
package com.APPNAME;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
public class BT_screen_splash extends BT_activity_base{
//properties...
String transitionType = "";
int startTransitionAfterSeconds = 0;
int transitionDurationSeconds = 0;
//onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.activityName = "BT_screen_splash";
BT_debugger.showIt(activityName + ":onCreate");
//set the content view...
LinearLayout baseView = (LinearLayout)findViewById(R.id.baseView);
//setup background colors...
BT_viewUtilities.updateBackgroundColorsForScreen(this, this.screenData);
//setup background images..
if(backgroundImageWorkerThread == null){
backgroundImageWorkerThread = new BackgroundImageWorkerThread();
backgroundImageWorkerThread.start();
}
//inflate this views layout file...
//inflate this screens layout file..
LayoutInflater vi = (LayoutInflater)thisActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View thisScreensView = vi.inflate(R.layout.screen_splash, null);
//add the view to the base view...
baseView.addView(thisScreensView);
/*
* *******************************************************************
* Notes:
* screen_splash.xml is an empty layout file. You can add whatever you
* want to it. The image for the splash screen is setup with the
* BT_viewUtilities.updateBackgroundColorsForScreen() method.
* That method sets the background image (the splash image) in this
* screens parent class. BT_activity_base. See above, almost all
* BT screens extend BT_activity_base
********************************************************************
*/
}
//onResume...
public void onResume(){
super.onResume();
//get values..
this.transitionType = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "transitionType", "");
this.startTransitionAfterSeconds = Integer.parseInt(BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "startTransitionAfterSeconds", "0"));
//setup transition if we don't have -1
if(startTransitionAfterSeconds > -1){
delayHandler.removeCallbacks(mDelayTask);
delayHandler.postDelayed(mDelayTask, ((startTransitionAfterSeconds + 1) * 1000));
}
}
//handle touch event..
@Override
public boolean onTouchEvent(MotionEvent event){
//BT_debugger.showIt("BT_screen_splash: touch event..");
//ignore touch events if we have a startTransitionAfterSeconds value..
if(startTransitionAfterSeconds < 1){
if(event.getAction() == MotionEvent.ACTION_DOWN){
animateSplashScreen();
}
}
return false;
}
/////////////////////////////////////////////////////////////////////
//handles question delay updates after each answer
Handler delayHandler = new Handler(){
@Override public void handleMessage(Message msg){
delayHandler.removeCallbacks(mDelayTask);
}
};
private Runnable mDelayTask = new Runnable() {
public void run() {
animateSplashScreen();
}
};
//end timer stuff
/////////////////////////////////////////////////////////////////////
//handles animation...
public void animateSplashScreen(){
BT_debugger.showIt("BT_screen_splash:animateSplashScreen");
//finish this screen so it cannot be returned to...
BT_screen_splash.this.finish();
//the next screen...
BT_item tmpLoadScreenObject = null;
BT_item tmpMenuItemObject = null;
tmpMenuItemObject = new BT_item();
tmpMenuItemObject.setItemId("tempMenuItem");
tmpMenuItemObject.setItemNickname("tempMenuItem");
try{
tmpMenuItemObject.setItemType("BT_menuItem");
tmpMenuItemObject.setJsonObject(new JSONObject("{\"transitionType\":\"fade\"}"));
}catch(Exception e){
}
//next screen to load...either tabbed home or the first screen in the list...
if(APPNAME_appDelegate.rootApp.getTabs().size() > 0){
BT_debugger.showIt("Building tabbed interface...");
//load BT_activity_root_tabs...
tmpLoadScreenObject = new BT_item();
tmpLoadScreenObject.setItemId("tmpRootTabs");
tmpLoadScreenObject.setItemNickname("tmpRootTabs");
try{
tmpLoadScreenObject.setItemType("BT_activity_root_tabs");
tmpLoadScreenObject.setJsonObject(new JSONObject("{}"));
}catch(Exception e){
}
}else{
//find the app's home screen...
tmpLoadScreenObject = APPNAME_appDelegate.rootApp.getHomeScreen();
//flag it as the home screen...
tmpLoadScreenObject.setIsHomeScreen(true);
}
//load...
if(tmpLoadScreenObject != null){
//remember current screen...
APPNAME_appDelegate.rootApp.setCurrentScreenData(tmpLoadScreenObject);
//load screen object...
BT_act_controller.loadScreenObject(this, this.screenData, tmpMenuItemObject, tmpLoadScreenObject);
}
}
}
答案 0 :(得分:2)
您将获得数字格式异常,因为您尝试将2.5转换为整数。
查看BT_Splash_screen.java中的第104行,找出您要进行的转换类型,并使其整数友好。
编辑:
这一行:
this.startTransitionAfterSeconds = Integer.parseInt(BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "startTransitionAfterSeconds", "0"));
是你的问题。它从你的json数据读取2.5并尝试将其解析为int。
答案 1 :(得分:0)
我看到你应该看的两件事。在Log Cat上,您有一个数字格式例外:无效的int 2.5。 Ints只能是整数。同样在控制台中,它告诉您正在使用已弃用的库。我会考虑改变这一点。如果可以,请发布一些代码,特别是数字格式异常,我们可以提供更好的帮助。