<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Dear Tizio,</p>
    <p>the debian build tools work like a charm, however I found the
      tutorial quite short and it took me a couple of hours to get
      everything to work. Therefore, I wrote a small "how-to" that
      explains how to compile an android app with the debian tools:<br>
    </p>
    <p>
      <style type="text/css">p { margin-bottom: 0.25cm; line-height: 120%; }a:link {  }</style>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%"><font face="Times
        New Roman, serif"><span lang="en-US">Debian
          stretch, which has been released in July 2017 (see
        </span></font><a
        href="https://bits.debian.org/2017/06/stretch-released.html"><font
          face="Times New Roman, serif">https://bits.debian.org/2017/06/stretch-released.html</font></a><font
        face="Times New Roman, serif"><span lang="en-US">),
          now includes all the </span></font><font face="Times New
        Roman, serif"><span lang="en-US">necessary</span></font><font
        face="Times New Roman, serif"><span lang="en-US">
          packages to build android apps from scratch ( see
        </span></font><a
href="https://bits.debian.org/2017/03/build-android-apps-with-debian.html"><font
          face="Times New Roman, serif">https://bits.debian.org/2017/03/build-android-apps-with-debian.html</font></a><font
        face="Times New Roman, serif"><span lang="en-US">
          ).</span></font><font face="Times New Roman, serif"> This
        means that you can build your Android app without using any
        proprietary software from Google. </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">As
        explained in the “Bits from Debian” blog
        (<a
href="https://bits.debian.org/2017/03/build-android-apps-with-debian.html">https://bits.debian.org/2017/03/build-android-apps-with-debian.html</a>),
        the Android Tools Team at the current point does not support
        everything that is possible with Android Studio and/or the
        binaries
        provided by Google, but it is more than sufficient to build your
      </font><font face="Times New Roman, serif">own
      </font><font face="Times New Roman, serif">open source app with
        the
        now available open source SDK. </font><font face="Times New
        Roman, serif">The
        available SDK packages make it possible to build Android apps
        against
        the API Level 23 (“Marshmellow”). As Android is an open source
        operating system, you now have an open source SDK.</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">However,
        I found the explanations given by the Android Tools Team very
        compact. In truth, it took me many hours to establish a working
        build
        environment and to build my first app with the Debian tools. For
        this
        reason, I found it worth to give some more explanations on how
        to do
        this.</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">1.
        Prerequisites</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">You
        need to install Debian Stretch. When saying Debian Stretch, I
        mean
        <a href="https://www.debian.org/releases/stretch/">https://www.debian.org/releases/stretch/</a>
        . As this stuff is very new to Debian, I do not know if it is
        already
        included in any Debian </font><font face="Times New Roman,
        serif">derivate</font><font face="Times New Roman, serif">
        like Ubuntu. Personally, I was not able to install the </font><font
        face="Times New Roman, serif">SDK
      </font><font face="Times New Roman, serif">successfully on Ubuntu
        16.04. You may take a pen drive and install Debian Stretch on it
        to
        test the </font><font face="Times New Roman, serif">SDK</font><font
        face="Times New Roman, serif">.
        That is the way I did it.</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">After
        running Debian Stretch, of course, there are some packages you
        need
        to install first:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">Do
        a fresh update of your packages database:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        update</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">Install
        the necessary packages to build an Android app:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">a)
        You need the openJDK: </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        install default-jdk</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">b)
        You need the Android SDK as outlined in
        <a
href="https://bits.debian.org/2017/03/build-android-apps-with-debian.html">https://bits.debian.org/2017/03/build-android-apps-with-debian.html</a>:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        install android-sdk android-sdk-platform-23</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">c)
        You need to install Gradle</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        install gradle</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">d)
        You need to install the Gradle-Android-Plugin</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        install libgradle-android-plugin-java</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">e)
        To properly sign your apk file after it is build, you need to
        install
        apksigner:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apt-get
        install apksigner</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">2.
        Short explanation on how the whole thing works with Gradle</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">Gradle
        is a build tool that we use to build Android apps. Basically,
        you
        create a file called build.gradle that describes what needs to
        be
        done to build your app. To build Android apps with Gradle and
        the SDK
        provided by the Debian Android Tools Team, you need some basic
        understanding on how Gradle works. </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">To
        get some understanding about gradle that goes beyond this short
        tutorial, you may have a look at
        <a
          href="http://tools.android.com/tech-docs/new-build-system/user-guide">http://tools.android.com/tech-docs/new-build-system/user-guide</a>
        that explains why and how Gradle is used for Android. <br>
      </font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"><br>
      </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">3.
        Define where your SDK is</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">In
        the top folder of your app project, you need to create a file
        called
        local.properties that says where your SDK is. In our case, this
        file
        needs to have the following single line:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">sdk.dir=/usr/lib/android-sdk</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">4.
        The project directory structure</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">Before
        building, you need to have a look at the </font><font
        face="Times New Roman, serif">structure</font><font face="Times
        New Roman, serif">
        of your app project. If you are coming from the eclipse plugin,
        you
        will notice that the default directory structure that gradle
        expects
        is a little bit different </font><font face="Times New Roman,
        serif">than
        what you are used to</font><font face="Times New Roman, serif">.
        This
        is well described here
        <a
          href="http://tools.android.com/tech-docs/new-build-system/user-guide">http://tools.android.com/tech-docs/new-build-system/user-guide</a>
        in the section “Project Structure”. Basically, you have to say
        Gradle in the build.</font><font face="Times New Roman, serif">gradle</font><font
        face="Times New Roman, serif">
        file what your structure looks like.</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">The
        typical and minimalistic structure of your Android app should
        look
        like this:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">MyAppProject</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> +src/main/AndroidMaifest.xml
        (your
        AndroidManifest.xml file)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> +src/main/java/ (your
        java source code goes here)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> +res/ (your
        resources go here)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> +build.gradle (your
        build.gradle file, see later)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> +local.properties (a
        file saying where your SDK is)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">5.
        Write the build.grade file for your app project</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">In
        the top folder of your app project, you need to create a file
        called
        build.gradle. This file describes what Gradle needs to do to
        build
        your app. For the needs of an Android app, the basic structure
        of
        this file is quite simple:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">buildscript
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> repositories
        { </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> //
        this defines a local maven repository that is installed with the
        sdk</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> maven
        {url “<a>file:///usr/share/maven-repo</a>”
        }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> dependencies
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> //
        this tells Gradle to use the gradle android plugin installed
        locally</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> classpath
        “com.android.tools.build:gradle:debian”</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">}</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">//
        this tells Gradle to use the android plugin defined above</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">apply
        plugin: “com.android.application”</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">android
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> //
        here goes the specific android stuff for your app. </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> CompileSDKVersion
        = 23</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> buildtoolsVersion=”24.0.0”</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> //
        we define that Lint errors do not abort the build process. </font>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> lintOptions
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> abortOnError
        false</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> //
        we define our directory structure, because it is not 100% what
        Gradle
        expects</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> souceSets
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> main
        {</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> java.srcDirs
        =[“src”]</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> res.srcDirs=[“res”]</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"> }</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">}</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">6.
        Build your project</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">Go
        into the top folder of your project (where the build.gradle file
        is)
        and run</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">gradle
        build</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">If
        everything went fine, you will find your unsigned apk file in
        build/outputs/apk/ named MyAppProject-unsigned.apk.</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">7.
        Sign your app before installation / publication</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">To
        install the apk file on an android device, you need to sign it
        with
        your key first. At this point, we assume you have a key to use
        for
        signing an app. (A self-signed key pair is sufficient! If you do
        not
        have one, please see the documentation of apksigner for
        details.)</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">In
        the build/outputs/apk/ directory, do the following:</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif"><font color="#000000"><span
            style="background: #ffffff">apksigner
            sign --ks </span></font><font color="#000000"><span
            style="background: #ffffff">yourkey</span></font><font
          color="#000000"><span style="background: #ffffff">.keystore
          </span></font><font color="#000000"><span style="background:
            #ffffff">MyAppProject-</span></font><font color="#000000"><span
            style="background: #ffffff">unsigned.apk </span></font></font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">8.
        End</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><font
        face="Times New Roman, serif">You
        have done it!</font></p>
    <p style="margin-bottom: 0cm; line-height: 100%" lang="en-US"><br>
    </p>
    <br>
    <div class="moz-cite-prefix">Am 02.10.2017 um 01:04 schrieb tizio
      incognito:<br>
    </div>
    <blockquote type="cite"
      cite="mid:1961907905.2743652.1506899067529@mail.yahoo.com">
      <pre wrap="">Acording to the tutorial in AndroidTools - Debian Wiki I should edit the file build.gradle, but I don't know where to find it.
  
|  
|   
|   
|   |    |

   |

  |
|  
|   |  
AndroidTools - Debian Wiki
   |   |

  |

  |

 

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Android-tools-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Android-tools-devel@lists.alioth.debian.org">Android-tools-devel@lists.alioth.debian.org</a>
<a class="moz-txt-link-freetext" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/android-tools-devel">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/android-tools-devel</a></pre>
    </blockquote>
    <br>
  </body>
</html>