I want to create my Android virtual device from another java application. I don't want to use the default Android AvdManager because you can't set where you want to create your AVD and it has problem with exotic caraters.
So I get the sdklib.jar of the AvdMagager and try to do this.
But I can't create a AVD because I have the log :
Error
Unable to find a '%1$s' file for ABI %2$s to copy into the AVD folder.
This is an exemple of what I do :
class Choice implements ISdkLog {
public Choice() {
com.android.sdklib.internal.avd.AvdManager avdmanager;
try {
com.android.sdklib.SdkManager manager = com.android.sdklib.SdkManager.createManager("Boulet", this);
IAndroidTarget[] targets = manager.getTargets();
avdmanager= new com.android.sdklib.internal.avd.AvdManager(manager,this);
avdmanager.createAvd(new java.io.File("filename"), "dunno", targets[0], "dunno", "dunno", "dunno", null, false, false, false, this);
} catch (AndroidLocationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//Method of interface ISdkLog
@Override
public void error(Throwable arg0, String arg1, Object... arg2) {
// TODO Auto-generated method stub
System.out.println("Error");
System.out.println(arg1);
System.out.println(arg0);
}
@Override
public void printf(String arg0, Object... arg1) {
// TODO Auto-generated method stub
System.out.println("Log");
System.out.println(arg0);
}
@Override
public void warning(String arg0, Object... arg1) {
// TODO Auto-generated method stub
System.out.println("Warning");
System.out.println(arg0);
}
}
This error is related to the system image the plateform must use. I could create my avd on windows with this.
AvdManager avdmanager;
try {
SdkManager manager = SdkManager.createManager("path/to/android/sdk/folder", this);
IAndroidTarget[] targets = manager.getTargets();
avdmanager= new AvdManager(manager,this);
avdmanager.createAvd(new File("custom/path/for/your/avd","advname"), "advname", targets[0], target[0].getSystemImages()[0].getAbiType(), null, null, null,
false, false, false, this);
} catch (AndroidLocationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
The null parameters are options for skin, sdcard path, emulator params (screen params,etc...).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.