@@ -148,7 +148,11 @@ public AnnotationsFinder() throws IOException {
148148 } catch (InterruptedException e ) {
149149 }
150150
151- File rawFolder = new File ("res" + File .separator + "raw" );
151+ String strRawFolder = "res" + File .separator + "raw" ;
152+ if (builtPath .toString ().startsWith ("build" )); //Check if running in AndroidStudio
153+ strRawFolder = "src" + File .separator + "main" + File .separator + "res" + File .separator + "raw" ;
154+
155+ File rawFolder = new File (strRawFolder );
152156 if (!rawFolder .exists ()) {
153157 rawFolder .mkdirs ();
154158 }
@@ -157,14 +161,14 @@ public AnnotationsFinder() throws IOException {
157161 if (onWindows ) {
158162 cmd = new String []{
159163 "cmd" , "/C" ,
160- "dx --dex --output=res " + File . separator + "raw" + File .separator + "anbuild.dex "
164+ "dx --dex --output=" + strRawFolder + File .separator + "anbuild.dex "
161165 + builtPath + File .separator + "anbuild.jar"
162166 };
163167 } else {
164168 cmd = new String []{
165169 getPathToDx (),
166170 "--dex" ,
167- "--output=res " + File . separator + "raw" + File .separator + "anbuild.dex" ,
171+ "--output=" + strRawFolder + File .separator + "anbuild.dex" ,
168172 builtPath + File .separator + "anbuild.jar"
169173 };
170174 }
@@ -175,12 +179,18 @@ public AnnotationsFinder() throws IOException {
175179 } catch (InterruptedException e ) {
176180 }
177181 }
178- System .out .println ("All done. ::: anbuild.dex should now be in your project's res" + File .separator + "raw" + File .separator + " folder :::" );
182+ System .out .println ("All done. ::: anbuild.dex should now be in your project's src" + File . separator + "main" + File . separator + " res" + File .separator + "raw" + File .separator + " folder :::" );
179183 }
180184
181185 protected void lookup (File path , List <File > fileList ) {
182- String desourcedPath = path .toString ().replace ("src" + File .separator , "" );
183- File [] files = path .listFiles ();
186+ String desourcedPath = path .toString ().replace ("src" + File .separator , "" ).replace ("main" + File .separator + "java" + File .separator , "" );
187+
188+ File [] files = path .listFiles (new FileFilter () {
189+ @ Override
190+ public boolean accept (File file ) {
191+ return true ;
192+ }
193+ });
184194 for (File file : files ) {
185195 if (file .isDirectory ()) {
186196 if (-1 == file .getAbsolutePath ().indexOf (AVOIDDIRPATH )) {
@@ -257,6 +267,8 @@ protected String getPathToDx() throws IOException {
257267 if (splitFileName [1 ].contains ("W" )) {
258268 char [] fileNameChars = splitFileName [1 ].toCharArray ();
259269 fileName = String .valueOf (fileNameChars [0 ]);
270+ } else if (splitFileName [1 ].contains ("rc" )) {
271+ continue ; //Do not use release candidates
260272 } else {
261273 fileName = splitFileName [1 ];
262274 }
@@ -309,6 +321,12 @@ public boolean accept(File pathname) {
309321 foundPath = eclipsePath ;
310322 }
311323 }
324+ if (null == foundPath ) {
325+ File androidStudioPath = new File ("build" + File .separator + "intermediates" + File .separator + "classes" + File .separator + "debug" ); // Android Studio
326+ if (androidStudioPath .isDirectory ()) {
327+ foundPath = androidStudioPath ;
328+ }
329+ }
312330
313331 return foundPath ;
314332 }
@@ -327,4 +345,4 @@ public static void main(String[] args) {
327345 displayError (e );
328346 }
329347 }
330- }
348+ }
0 commit comments