How to compile an Android app with aapt2 without using any build tools?

前端 未结 2 832
感动是毒
感动是毒 2020-12-21 20:09

I\'m trying to compile an Android application I just created in Kotlin on Android Studio, without using Gradle or any other build tools. My intention is to speed up compilin

相关标签:
2条回答
  • 2020-12-21 20:49

    Actually it is very difficult and messy to use extra support libraries, You are getting those errors, because you are using support library's theme which is not a part of android.jar, Instead you can use android.jar's default theme. Just put

    public  class MainActivity extends Activity {...}
    

    in place of

    public  class MainActivity extends AppCompatActivity {...}
    

    and change your manifest's App theme pointing to 'styes.xml', So basically you have to change the styles XML file to this one

    <resources>
    
        <!--
            Base application theme, dependent on API level. This theme is replaced
            by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
        -->
        <style name="AppBaseTheme" parent="android:Theme.Light">
            <!--
                Theme customizations available in newer API levels can go in
                res/values-vXX/styles.xml, while customizations related to
                backward-compatibility can go here.
            -->
        </style>
    
        <!-- Application theme. -->
        <style name="AppTheme" parent="AppBaseTheme">
            <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        </style>
    
    </resources>
    

    Also you should use below code in 'Manifest.xml' file to point the Theme of your project or Activity in Styles XML file under values

    android:theme="@style/AppTheme"
    

    this reference article is very helpful for what exactly you are trying to dohttps://geosoft.no/development/android.html, Also sign your APK in order to run your app on device, otherwise it can show error while installing. Thanks.

    0 讨论(0)
  • 2020-12-21 20:51

    Use the below link for reference of using aapt/appt2 for compiling java app, so that you can make one for compiling kotlin on your own.

    https://github.com/HemanthJabalpuri/AndroidExplorer

    0 讨论(0)
提交回复
热议问题