Little simple things where I lost some time finding out the resolution when developing for Android.
Emulator with PANIC error:
PANIC: Could not open: C:\Users\
This error happens all the time in windows environment. The most cause is because your username has some non-english characters like “éáç…”, and Android SDK uses your home folder in the operating system as a default to create the emulators.
Possible solution:
make a copy of the avd folder and configure the ini file to point to the new folder.
Go to the emulator folder (for instance: c:\users\usernamewithnonenglishlike-áéíç\.android\avd\)
Copy the “avd” folder to another folder without non-english characters (c:\myAvds\…")
Don’t remove the original
In the original folder open the “init” file: (for instance: c:\users\usernamewithnonenglishlike-á\.android\avd\AVD_for_2_7in_QVGA.ini)
Change the path value to the new folder:
- path=newFolderWithoutNonEnglishCharacters\avd\AVD_for_2_7in_QVGA.avd
- Start the emulator, it must work now!
PS: Another way is creating manually the AVD and place it in a custom folder:
1 |
<em>android create avd -n myVirtualDevice -t 2 -p customfolder\avd</em> |
1 |
Associate the resource layout (xml file) with the Activity java class:
In the activity java file just add a line to link to the resource file.
Create your resource file or “design file” at res\layout\your_resource.xml
- use only lowercase characters combined with numbers and “_”
- In the Activity Java Class, in the “onCreate” method, use “setContentView(R.layout.your_resource) like the code below.
1 |
<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> onCreate(Bundle savedInstanceState) { |
1 |
<span style="color: #0000ff;">super</span>.onCreate(savedInstanceState); |
1 |
1 |
<span style="color: #008000;">// Your xml resource file!</span> |
1 |
setContentView(R.layout.resource_file); |
1 |
} |
Can’t configure Android SDK in IntelliJ 12 when creating a new project
Intellij doesn’t have configured any jdk, so we must configure at least one!
- Create the project without the Android SDK configured.
- Add some jdk (1.5, 1.6, 1.7) in File->Project Structure
- Then choose Android SDK for your project!