@@ -17,7 +17,7 @@ public class AVD {
17
17
static private final String AVD_CREATE_SECONDARY =
18
18
"The default Android emulator could not be set up. Make sure<br>" +
19
19
"that the Android SDK is installed properly, and that the<br>" +
20
- "Android and Google APIs are installed for level %s .<br>" +
20
+ "Android and Google APIs are installed for level " + AndroidBuild . sdkVersion + " .<br>" +
21
21
"(Between you and me, occasionally, this error is a red herring,<br>" +
22
22
"and your sketch may be launching shortly.)" ;
23
23
@@ -48,96 +48,53 @@ public class AVD {
48
48
/** x86, x86_64 or armeabi **/
49
49
protected String abi ;
50
50
51
- protected VirtualDevice virtualDevice ;
52
-
53
51
public static final String PREF_KEY_ABI = "android.sdk.abi" ;
54
52
public static final String [] ABI = {"armeabi" , "x86" , "x86_64" };
55
53
56
54
/** Default virtual device used by Processing. */
57
55
static public AVD defaultAVD ;
58
56
// "Google Inc.:Google APIs:" + AndroidBuild.sdkVersion);
59
57
60
- static ArrayList <VirtualDevice > avdList ;
61
- static ArrayList <VirtualDevice > badList ;
62
-
63
-
64
- private static class VirtualDevice {
65
- public String name ;
66
- public String target ;
67
- public String abi ;
68
- public VirtualDevice (String name , String target , String abi ) {
69
- this .name = name ;
70
- this .target = target ;
71
- this .abi = abi ;
72
- }
58
+ static ArrayList <String > avdList ;
59
+ static ArrayList <String > badList ;
60
+ // static ArrayList<String> skinList;
73
61
74
- @ Override
75
- public boolean equals (Object o ) {
76
- VirtualDevice device = (VirtualDevice ) o ;
77
- if (device .name .equals (name ) && device .target .equals (target )
78
- && device .abi .equals (abi )) {
79
- return true ;
80
- }
81
- return false ;
82
- }
83
- }
84
-
85
62
86
63
public AVD (String name , String target , String abi ) {
87
64
this .name = name ;
88
65
this .target = target ;
89
66
this .abi = abi ;
90
- virtualDevice = new VirtualDevice (name , target , abi );
91
67
}
92
68
93
69
94
70
static protected void list (final AndroidSDK sdk ) throws IOException {
95
71
try {
96
- avdList = new ArrayList <VirtualDevice >();
97
- badList = new ArrayList <VirtualDevice >();
72
+ avdList = new ArrayList <String >();
73
+ badList = new ArrayList <String >();
98
74
ProcessResult listResult =
99
75
new ProcessHelper (sdk .getAndroidToolPath (), "list" , "avds" ).execute ();
100
76
if (listResult .succeeded ()) {
101
77
boolean badness = false ;
102
- String mTarget = null ;
103
- String mAbi = null ;
104
- String mName = null ;
105
78
for (String line : listResult ) {
106
79
String [] m = PApplet .match (line , "\\ s+Name\\ :\\ s+(\\ S+)" );
107
80
if (m != null ) {
108
- mName = m [1 ];
109
- continue ;
110
- }
111
-
112
- m = PApplet .match (line , "API\\ slevel\\ s([0-9]+)" );
113
- if (m != null ) {
114
- mTarget = m [1 ];
115
- continue ;
116
- }
117
-
118
- m = PApplet .match (line , "\\ s+Tag\\ /ABI\\ :\\ s\\ S+\\ /(\\ S+)" );
119
- if (m != null ) {
120
- mAbi = m [1 ];
121
- }
122
-
123
- if (mName != null && mTarget != null && mAbi != null ) {
124
- VirtualDevice mVirtualDevice = new VirtualDevice (mName , mTarget , mAbi );
125
- mTarget = null ;
126
- mAbi = null ;
127
81
if (!badness ) {
128
- avdList .add (mVirtualDevice );
82
+ // System.out.println("good: " + m[1]);
83
+ avdList .add (m [1 ]);
129
84
} else {
130
- badList .add (mVirtualDevice );
85
+ // System.out.println("bad: " + m[1]);
86
+ badList .add (m [1 ]);
131
87
}
88
+ // } else {
89
+ // System.out.println("nope: " + line);
132
90
}
133
-
134
91
// "The following Android Virtual Devices could not be loaded:"
135
92
if (line .contains ("could not be loaded:" )) {
136
93
// System.out.println("starting the bad list");
137
94
// System.err.println("Could not list AVDs:");
138
95
// System.err.println(listResult);
139
96
badness = true ;
140
- break ;
97
+ // break;
141
98
}
142
99
}
143
100
} else {
@@ -152,9 +109,15 @@ protected boolean exists(final AndroidSDK sdk) throws IOException {
152
109
if (avdList == null ) {
153
110
list (sdk );
154
111
}
155
- virtualDevice .target = AndroidBuild .sdkVersion ;
156
- virtualDevice .abi = abi ;
157
- return avdList .contains (virtualDevice );
112
+ for (String avd : avdList ) {
113
+ if (Base .DEBUG ) {
114
+ System .out .println ("AVD.exists() checking for " + name + " against " + avd );
115
+ }
116
+ if (avd .equals (name )) {
117
+ return true ;
118
+ }
119
+ }
120
+ return false ;
158
121
}
159
122
160
123
@@ -164,7 +127,12 @@ protected boolean exists(final AndroidSDK sdk) throws IOException {
164
127
* (Prestigious may also not be the right word.)
165
128
*/
166
129
protected boolean badness () {
167
- return badList .contains (virtualDevice );
130
+ for (String avd : badList ) {
131
+ if (avd .equals (name )) {
132
+ return true ;
133
+ }
134
+ }
135
+ return false ;
168
136
}
169
137
170
138
@@ -197,8 +165,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
197
165
} else {
198
166
// Just generally not working
199
167
// Base.showWarning("Android Error", AVD_CREATE_ERROR, null);
200
- Base .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY ,
201
- String .format (AVD_CREATE_SECONDARY , AndroidBuild .sdkVersion ), null );
168
+ Base .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY , AVD_CREATE_SECONDARY , null );
202
169
System .out .println (createAvdResult );
203
170
// throw new IOException("Error creating the AVD");
204
171
}
@@ -211,8 +178,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
211
178
212
179
static public boolean ensureProperAVD (final AndroidSDK sdk , final String abi ) {
213
180
try {
214
- defaultAVD = new AVD ("Processing-0" + Base .getRevision () + "-" + AndroidBuild .sdkVersion +
215
- "-" + abi ,
181
+ defaultAVD = new AVD ("Processing-0" + Base .getRevision (),
216
182
"android-" + AndroidBuild .sdkVersion , abi );
217
183
if (defaultAVD .exists (sdk )) {
218
184
// System.out.println("the avd exists");
@@ -229,10 +195,8 @@ static public boolean ensureProperAVD(final AndroidSDK sdk, final String abi) {
229
195
return true ;
230
196
}
231
197
} catch (final Exception e ) {
232
- e .printStackTrace ();
233
198
// Base.showWarning("Android Error", AVD_CREATE_ERROR, e);
234
- Base .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY ,
235
- String .format (AVD_CREATE_SECONDARY , AndroidBuild .sdkVersion ), null );
199
+ Base .showWarningTiered ("Android Error" , AVD_CREATE_PRIMARY , AVD_CREATE_SECONDARY , null );
236
200
}
237
201
System .out .println ("at bottom of ensure proper" );
238
202
return false ;
0 commit comments