开发者

Can't get emulator to reflect minor changes I made to HelloAndroid app

I was able to run the HelloAndroid app on the emulator, running on my Mac and using Eclipse. I was hoping I could keep adding code to test new features, but can't get the emulator to reflect any changes. Even just changing the tv.setText text doesn'开发者_开发百科t work - the emulator keeps showing the original text. I am not getting any error codes, so why are the changes taking?


Are you looking for Errors in Console? Android will not show much info in Console. Try using LogCat.

I have noticed that if you just change the xml and try to launch app, the app will not show the changes. However, I can see that the code has changed.

One suggestion is to run application in debug mode (no need for any breakpoints) rather then run mode.

Other suggestion is to clean the project (Project --> Clean from Eclipse).


I had exactly the same problem and it took me a while to figure out how to get my app changes installed onto the emulator.

Basically i noticed the problem was, when launching from the Eclipse ADT plugin, the emulator device was not showing up on the adb (android debug bridge).

Below are the commands i executed to check for the list of devices on adb (I am running using Windows 7.):

cd C:\Program Files (x86)\Android\android-sdk\platform-tools

adb devices

So to work around this, i would launch the emulator.

Next i would kill the adb.exe process.

Then i would manually restart the adb.exe process by just executing >adb devices

Now you should see the emulator device connected, example:

List of devices attached

emulator-5554 device

Now just go back to eclipse and click 'Run'.

On the console window in Eclipse you should see something like this:

[2013-05-12 18:28:43 - MyFirstApp] Android Launch!

[2013-05-12 18:28:43 - MyFirstApp] adb is running normally.

[2013-05-12 18:28:43 - MyFirstApp] Performing com.example.myfirstapp.MainActivity activity launch

[2013-05-12 18:28:43 - MyFirstApp] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'test_emu'

[2013-05-12 18:28:43 - MyFirstApp] Uploading MyFirstApp.apk onto device 'emulator-5554'

[2013-05-12 18:28:44 - MyFirstApp] Installing MyFirstApp.apk...

[2013-05-12 18:28:58 - MyFirstApp] Success!

[2013-05-12 18:28:58 - MyFirstApp] Starting activity com.example.myfirstapp.MainActivity on device emulator-5554

[2013-05-12 18:29:00 - MyFirstApp] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.myfirstapp/.MainActivity }

Go to the emulator window and your app should be running and reflecting your latest code changes.

Don't close the emulator, or else you will have to repeat the process of killing and manually restarting the adb.exe again.


How are you expecting it to reflect the changes? You have to recompile and send the apk back to the device every time. Clicking the run button should do that for you.


Change the code and then, having your project selected, Run -> Run As -> Android Application, the new application is installed and run.


I suggest using xml to edit your application. Simply change your text view code with this

 setContentView(R.layout.main);

Then go to your main.xml and change it to this

<TextView
android:id="@+id/YourTextView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="YOUR TEXT HERE"

>
</TextView>

This will allow you to easily change TextView content and add other "widgets". If you don't want to bother with coding xml I suggest http://www.droiddraw.org/. Hope this helped

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜