ASUS eeeでデバッグしようとしているアプリケーションTF101 (ルーテッドではない)が動作していません。 Esclipseで "debug"をクリックするたびに、私のASUSは "アプリケーション....が予期せず停止しました。もう一度やり直してください"と表示します。エラーメッセージ。私はEVO(rooted)とDroidX(root以外)に何も問題なく走らせることができます。適用可能なすべての設定が適用されていることを確認しましたが(Setting up a Device for Development)、それでも動作しません。奇妙な部分は、私がのonCreateイベントにコードの2行目にブレークポイントを置けば、それもそこに壊れないですEclipseはASUS eee TF101でデバッグしません
boolean bNetworkConnected = true;
を「私は、単純な代入文がブレークポイントのために働くと考えましたが、それはdoesnのそこに壊れない。
何が起こっているかについてのアイデアはありますか?
UPDATE
マキシム、私はどちらかのリリースモードでそれを実行することはできません。 MainActivityがマニフェストファイルで指定されたものであることを確認しました(これは私のevoとdroidxで実行されます)。ここで私はリリースモードでそれを実行したLogCatのコピーです:
02-14 10:31:21.107: D/dalvikvm(5934): GC_FOR_ALLOC freed 43K, 4% free 6370K/6595K, paused 40ms
02-14 10:31:21.117: I/dalvikvm-heap(5934): Grow heap (frag case) to 6.767MB for 513744-byte allocation
02-14 10:31:21.157: D/dalvikvm(5934): GC_FOR_ALLOC freed <1K, 4% free 6872K/7111K, paused 25ms
02-14 10:31:21.197: E/GetStringFromWebService ERROR-(5934): java.lang.RuntimeException: android.os.NetworkOnMainThreadException
02-14 10:31:21.207: E/GetStringFromWebService ERROR-(5934): java.lang.RuntimeException: android.os.NetworkOnMainThreadException
02-14 10:31:21.207: E/GetIntFromWebService ERROR-(5934): java.lang.RuntimeException: java.lang.NumberFormatException: Invalid int: "null"
02-14 10:31:21.207: E/GetStringFromWebService ERROR-(5934): java.lang.RuntimeException: android.os.NetworkOnMainThreadException
02-14 10:31:21.207: D/AndroidRuntime(5934): Shutting down VM
02-14 10:31:21.207: W/dalvikvm(5934): threadid=1: thread exiting with uncaught exception (group=0x40221760)
02-14 10:31:21.227: D/dalvikvm(5934): GC_CONCURRENT freed 67K, 3% free 6908K/7111K, paused 2ms+4ms
02-14 10:31:21.227: E/AndroidRuntime(5934): FATAL EXCEPTION: main
02-14 10:31:21.227: E/AndroidRuntime(5934): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.adacel.app/com.adacel.app.MainActivity}: java.lang.NullPointerException
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread.access$500(ActivityThread.java:122)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.os.Looper.loop(Looper.java:132)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread.main(ActivityThread.java:4123)
02-14 10:31:21.227: E/AndroidRuntime(5934): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 10:31:21.227: E/AndroidRuntime(5934): at java.lang.reflect.Method.invoke(Method.java:491)
02-14 10:31:21.227: E/AndroidRuntime(5934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
02-14 10:31:21.227: E/AndroidRuntime(5934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
02-14 10:31:21.227: E/AndroidRuntime(5934): at dalvik.system.NativeStart.main(Native Method)
02-14 10:31:21.227: E/AndroidRuntime(5934): Caused by: java.lang.NullPointerException
02-14 10:31:21.227: E/AndroidRuntime(5934): at com.adacel.app.MainActivity.GetLatestData(MainActivity.java:300)
02-14 10:31:21.227: E/AndroidRuntime(5934): at com.adacel.app.MainActivity.LoadWithNetworkConnectivity(MainActivity.java:220)
02-14 10:31:21.227: E/AndroidRuntime(5934): at com.adacel.app.MainActivity.onCreate(MainActivity.java:79)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.Activity.performCreate(Activity.java:4397)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
02-14 10:31:21.227: E/AndroidRuntime(5934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
02-14 10:31:21.227: E/AndroidRuntime(5934): ... 11 more
それは方法GetStringFromWebServiceに出erroringだかのようにそれが表示されます。しかし、奇妙な部分はこれです.... MainActivityでさらに呼び出されるまで呼び出しは行われません。上の私の代入呼び出し(bNetworkConnected = true)はコードの2行目で、super.onCreate(savedInstance)の直後です。 ..それは私がそこに設定したブレークポイントも見ないようなものです。
MainActivityコード
public static final String TAG = "SQLiteDebug";
private ListView mListViewIssues;
private static final String NameSpace = "RemoteWebService";
private static final String URL = "http://ws.simcare.biz/Service1.asmx";
private static final String DBVersionKey = "DBVersion";
private static final String PreferencesNotLoaded = "User Preferences could not be loaded. \n\nThis app will now close.";
private static final String CustomerCodeNotLoaded = "The Customer Code could not be loaded. \n\nThis app will now close.";
private static final String LocationShortNameNotLoaded = "The Location Short Name could not be loaded. \n\nThis app will now close.";
private static final String DBVersionNotLoaded = "The Database Version could not be loaded. \n\nThis app will now close.";
private static final String App_File = "app_file.xml";
private static final String AppNotConnectedTitle = "App Not Connected to Network";
Boolean ConnectedToNetwork = false;
TextView tvFooter;
int DBVersion = 1;
IssueInfoCreator creator;
AppPreferences appPrefs = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.footer_layout);
//For testing network connectivity only.
boolean bNetworkConnected = true;
//If there's a network connection available, get latest data.
//if(NetworkUtils.getInstance(this).isOnline(this)){
if(bNetworkConnected){
//Load data from web service and get latest data.
LoadWithNetworkConnectivity();
}
else{
InputStream isAppFile = null;
try {
isAppFile = getBaseContext().getAssets().open(App_File);
} catch (IOException e) {
ShowMessageAndClose(PreferencesNotLoaded);
return;
}
Scanner scanner = new Scanner(isAppFile);
String sScannerContents = scanner.useDelimiter("\\A").next();
Document doc = XMLfunctions.XMLfromString(sScannerContents);
try{
if(LoadPreferences(doc))
DBVersion = Integer.valueOf(appPrefs.getDBVersion());
}catch(Exception ex){
Log.e("INT PARSE ERROR", ex.getStackTrace().toString());
}
//Load data from local db only.
LoadWithoutNetworkConnectivity();
}
//Load listview control.
setContentView(R.layout.main);
//Setup Refresh button listener.
Button btn = (Button) findViewById(R.id.btnRefresh);
btn.setOnClickListener(btnRefreshClick);
final Context context = getBaseContext();
mListViewIssues = (ListView)findViewById(R.id.listIssues);
//Load Footer View.
View footerView =((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
tvFooter = (TextView)footerView.findViewById(R.id.footerText);
tvFooter.setText("DBVersion = " + String.valueOf(DBVersion));
mListViewIssues.addFooterView(footerView);
creator = new IssueInfoCreator(this, DBVersion);
creator.open();
//add data to listview through adapter.
mListViewIssues.setAdapter(new IssueInfoAdapter(this, creator.queryAll()));
creator.close();
}
LoadWithNetworkConnectivityコード:
private void LoadWithNetworkConnectivity(){
//Set the Titlebar to the stored value in the DB.
String SoapAction = "RemoteWebService/GetApplicationTitle";
String MethodName = "GetApplicationTitle";
setTitle(GetStringFromWebService(NameSpace, MethodName, SoapAction, URL, "ApplicationName", "AndroidApp"));
//Get the DBVersion.
SoapAction = "RemoteWebService/GetDBVersion";
MethodName = "GetDBVersion";
DBVersion = GetIntFromWebService(NameSpace, MethodName, SoapAction, URL, "ApplicationName", "AndroidApp");
//Write DBVersion to Preferences.
Editor ePreferences = this.getPreferences(Context.MODE_PRIVATE).edit();
ePreferences.putInt(DBVersionKey, DBVersion);
ePreferences.commit();
//Get Issues for this Customer/Location.
SoapAction = "RemoteWebService/GetOpenIssues";
MethodName = "GetOpenIssues";
SoapPrimitive xmlData = GetDataFromWebService(NameSpace, MethodName, SoapAction, URL, "ApplicationName", "AndroidApp");
try {
GetLatestData(xmlData);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//Set flag.
ConnectedToNetwork = true;
}
GetDataFromWebServiceコード:
public SoapPrimitive GetDataFromWebService(String NameSpace, String MethodName, String SoapAction, String URL, String argName, String argValue){
try {
SoapObject request = new SoapObject(NameSpace, MethodName);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
request.addProperty(argName, argValue);
if(MethodName == "GetOpenIssues")
{
request.addProperty("CustomerCode", "ABC");
request.addProperty("LocationShortName", "KBIF");
}
envelope.setOutputSoapObject(request);
androidHttpTransport.call(SoapAction, envelope);
SoapPrimitive responseData = (SoapPrimitive) envelope.getResponse();
return responseData;
}
catch (Exception e) {
Log.e("GetStringFromWebService ERROR-", new RuntimeException(e).toString());
return null;
}
}
GetLatestDataコード:
public void GetLatestData(SoapPrimitive xml)throws ParserConfigurationException, SAXException, IOException{
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc;
//parse using builder to get DOM representation of the XML file
InputSource is = new InputSource(new StringReader(xml.toString()));
doc = db.parse(is);
//Clear out Issues table first.
creator = new IssueInfoCreator(this, DBVersion);
creator.open();
creator.ClearIssueTable();
creator.close();
NodeList nodes = doc.getElementsByTagName("Table");
for(int i = 0; i < nodes.getLength(); i++) {
IssueInfo issue = new IssueInfo();
Element e = (Element)nodes.item(i);
issue.setIssueNumber(Long.parseLong(XMLfunctions.getValue(e, "IssueID")));
issue.setIssueSummary(XMLfunctions.getValue(e, "IssueSummary"));
issue.setDateReceived(DateFormat.format("MM/dd/yyyy hh:mm:ss", System.currentTimeMillis()).toString());
if(issue.getIssueNumber() > 0 && issue.getIssueSummary() != null){
creator = new IssueInfoCreator(this, DBVersion);
creator.open();
creator.InsertIssue(issue.getIssueNumber(), issue.getDateReceived(), issue.getIssueSummary());
creator.close();
}
}
}
あなたは要求されたコードがありますが....要するに、アプリが起動し、(このケースでは、私はちょうどブールフラグを入れて、有効なネットワーク接続があるかどうかをチェック私はケーブルを抜いたり、wifiを外して作業をしたり、動作させたりする必要はありません)、適切な方法で動作します。私はこのフラグをtrueに設定してLoadWithNetworkConnectivity()メソッドを呼び出します。このメソッドは.NET Webサービスに送られ、アプリケーションのタイトル、DBVersion、およびOpenIssuesを取得します。このメソッドでは、次に "GetLatestData"メソッドを呼び出し、XMLを作成したIssueオブジェクトに解析します。ここでも、私のASUSタブレットではなく、エミュレータ、evo、およびdroidxのすべてが動作しています。
UPDATE#2 - 解決
私は(私が前に2.3.3エミュレータ上でそれを実行していた)デバッグに私のタブレットを取得しようと努力をスキップし、3.2 OSのためのエミュレータを作成しました。だから私はデバッグし、エラーがどこから来ているか見ることができます。最初の次の行に出てエラーに表示されます。
setTitle(GetStringFromWebService(NameSpace, MethodName, SoapAction, URL, "ApplicationName", "AndroidApp"));
私は、文字列でこれを置く場合、それはnullを返し、私はLogCatに入るエラーがある:
02-14 16:01:21.177: E/GetStringFromWebService ERROR-(510): java.lang.RuntimeException: android.os.NetworkOnMainThreadException
マキシムが言ったと同じように、あなたはそれ自身のスレッドの上にネットワーキングのものを置く必要があります。 Android SDKのドキュメントでは、NetworkOnMainThreadExceptionについても説明しています。 Unrealはそこに書かれていることを言います...古いプラットフォームでは許可されていますが、Honeycomb以上では許可されていません。これはASUSのタブレットが実行しているもので、これがエラーの原因です。
ありがとうございました!ネットワーキングイベントを自分のスレッドに入れるコードを入手したら、この投稿を更新して他の人に知らせるようにします。
私はTF101のすべてをデバッグできます。デバッグモードではなくアプリを実行するとクラッシュしますか?それはあなたの主な打ち上げ活動ですか?そうでない場合は、マニフェストファイルの別のアクティビティを宣言しましたか? LogCatがここで助けてくれるだろう。 – Maxim
'MainActivity'コードを投稿できますか?特にcom.adacel.app.MainActivity.GetLatestData'メソッド – SERPRO
アクティビティを開始できませんComponentInfo {com.adacel.app/com.adacel.app.MainActivity}:java.lang.NullPointerException、これはあなたがオブジェクトとそのnullから何かを取得しようとしています。また、ERROR-(5934):java.lang.RuntimeException:java.lang.NumberFormatException:無効なint: "null"。まず、WebServiceコールが(NetworkOnMainThreadException)のために別のスレッドで実行されていることを確認します。次に、サービスから正しいデータを取得しています。 LoadWithNetworkConnectivity()内を見てください – Maxim