Android-需要一种无需源代码即可创建库(.aar文件)的方法 [英] Android - Need a way to create the library(.aar file) without source code

查看:244
本文介绍了Android-需要一种无需源代码即可创建库(.aar文件)的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是能够将Android库应用程序仅以二进制形式(不提供源代码)分发给其他开发人员. 这样他们就可以用它制作自己的应用程序.

我正在开发两个android应用程序.第一个是库应用程序应充当一种SDK. 第二个应用程序应使用库应用程序并制作原始应用程序.

我正在使用android studio开发应用程序.我已经完成了库应用程序的实现并生成了.aar.

现在,我正在使用自己的SDK(.aar)来构建第二个应用程序.我可以在第二个应用程序中使用.aar.

问题在于,android studio可以反编译我的SDK(.aar).但是我不想共享源代码.

注意:我的librarySDK不包含任何UI元素,例如活动",资源".

是否可以在没有源代码的情况下创建SDK(.aar)?

解决方案

是的,因为在构建 SDK/库文件文件时需要使用 proguard >

在SDK/库gradle中将minifyEnabled更改为true

buildTypes {
        release {
            minifyEnabled true //enable proguard
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

在Eclipse中为Android启用ProGuard

My aim is to be able to distribute the android library application only as binary(WITHOUT SOURCE) to other developers. So that they can make their own apps with it.

I am developing two android applications. The first one is library application should act as a kind of SDK. The second one application should use the library application and make the original app.

I am using android studio to develop the applications. I have completed the implementations of the library application and generated the .aar.

Now I am using my own SDK(.aar) to build the second application. I can use the .aar in my second application.

The problem is that, android studio can decompile my SDK(.aar). But I don't want to share the source code.

Note: My librarySDK doesn't contain any UI elements such as Activity, Resources.

Is there any way to create the SDK(.aar) without source code?

解决方案

yup for that you need to use proguard when you build SDK/Library aar file

Change minifyEnabled to true in your SDK/Library gradle

buildTypes {
        release {
            minifyEnabled true //enable proguard
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

Enabling ProGuard in Eclipse for Android

这篇关于Android-需要一种无需源代码即可创建库(.aar文件)的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆