1

I have previously only once built an Android project successfully on my Linux machine; for that, I downloaded the Android SDK and ultimately used gradlew to build it, which worked fine.

Now, I got a zip containing an Android project source code; however, as I'm not experienced with this, I have no idea what this project was made in, nor how was it built. The directory structure looks like this:

.
├── AndroidManifest.xml
├── assets
├── bin
│   ├── AndroidManifest.xml
│   ├── classes
│   │   └── com # ... .class files here
...
│   ├── jarlist.cache
│   └── res
├── gen
│   └── com     # ... BuildConfig.java here
...
│   └── android-support-v4.jar
├── lint.xml
├── proguard-project.txt
├── project.properties
├── res
│   ├── drawable       # ... .png files here
...
│   ├── drawable-hdpi  # many similar dirs, launcher.png file
...
│   ├── layout         # main.xml and other .xml files
...
│   ├── raw            # some .json files here
...
│   ├── values         # also values-v11, values-v14 dirs; has styles.xml
...
└── src
    └── com            # .java source files here
...

I have tried How/when to generate Gradle wrapper files? in this directory (that is, gradlew wrapper and gradlew init), but even if gradle-specific files are generated, I cannot build that - since I cannot run gradlew assemble or gradlew build, as I get "Task 'assemble' not found in root project".

After finding Build Android project on command line on OSX: Task 'assembleDebug' not found in root project, I thought maybe it has to be compiled with ant, but that fails with "Buildfile: build.xml does not exist!" (and indeed, such a file doesn't exist).

From what I read around, I guess one should download Android Studio and try opening the project there -- but I'd rather not download/learn/use yet another IDE (I use a standalone text editor and I don't use, say, Eclipse), and would rather get this done through the command line.

So how could I "re-initialize" this project, so I can build it with command line tools on Linux (gradle or ant, though I guess gradle is preferred, as apparently ant is not currently supported by Android team)?

Community
  • 1
  • 1
sdaau
  • 36,975
  • 46
  • 198
  • 278

1 Answers1

0

Ok, I found that there was actually a hidden file in this project, .project, which has for instance:

<buildCommand>
  <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
  <arguments>
  </arguments>
</buildCommand>

... which means this had been built with Eclipse with ADT plugin ( http://developer.android.com/sdk/installing/installing-adt.html ), the support for which is now discontinued in favor of Android Studio ( Migrating to Android Studio | Android Developers ).

Knowing this, then I simply found How to create build.xml for an Android project? and ant command does not generating apk file, from where I tried the command:

/path/to/sdk/tools/android update project -p $PWD

... which finally did create build.xml that is used by the ant system - which seemed to pass (but the build itself failed due to unresolved library dependencies, which is a different topic).

There seems to be no easy way to convert an ant based project to a gradle one from the command line - and even the migration path through the Android Studio may/will require manual changes.

Community
  • 1
  • 1
sdaau
  • 36,975
  • 46
  • 198
  • 278