标签: android-library

获取Android库中源代码的校验和

我正在开发一个Android库,我想在我的代码中应用篡改检测机制,因为它调用了一些敏感的金融Web服务.

我要实现的是在运行时以编程方式计算apk(或其重要部分)的校验和,这样我就可以防止重新打包或重新编译的apk能够造成任何伤害(防篡改).

到目前为止,我想出的是计算校验和applicationInfo.publicSourceDir.但我不确定具有多个dex文件或多个splitApks的应用程序会发生什么.

以编程方式基于Android应用程序的代码库计算校验和的最可靠方法是什么?

java android dex android-library android-security

14
推荐指数
1
解决办法
950
查看次数

在 com.android.build.gradle.LibraryExtension 类型的扩展“android”上找不到参数 [com.android.mylib] 的方法命名空间()

我正在尝试按照此官方文档在 android studio 中创建一个库。但在这个特定的项目中,我面临着这个问题。如果我创建新项目并创建新库,我不会遇到任何问题。这意味着仅此项目有问题。

我的 Lib Gradle

插件 { id 'com.android.library' }

android {
    namespace 'com.android.mylib'
    compileSdkVersion 33

defaultConfig {
    minSdkVersion 26
    targetSdkVersion 33

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)

}

应用程序摇篮

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 33
    buildToolsVersion "30.0.2"
    testBuildType "beta"

    defaultConfig {
        applicationId "com.app.etc"
        minSdkVersion 23
        targetSdkVersion 33
        versionCode 327
Run Code Online (Sandbox Code Playgroud)

我搜索了一些问题,但根据这些答案,一切似乎都是正确的。我已经使缓存失效并重新启动了android studio。 …

gradle android-library android-studio build.gradle android-gradle-plugin

14
推荐指数
1
解决办法
2万
查看次数

有没有办法在一个项目中使用Roboguice和ActionbarSherlock?

我想在一个项目中使用标题中提到的库.

但是,两者都需要我的活动从一个特殊的Activity类扩展:在Roboguice的情况下它是RoboAcitivity,它是ActionbarSherlock的FragmentActivity.

ActionbarSherlock扩展了兼容性库,这很好,因为我还需要使用片段,而项目级别是<API级别11.

有人有成功吗?由于Java不支持多重继承(通常这是一件好事),我试图在ActionbarSherlock项目中使用FragmentActivity来扩展RoboActivity而不是标准的Activity.但我无法通过这种方式进行编译.

控制台输出的一部分是:

[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:170: error: Error: No resource found that matches the given name: attr 'android:logo'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:171: error: Error: No resource found that matches the given name: attr 'android:navigationMode'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:174: error: Error: No resource found that matches the given name: attr 'android:progressBarPadding'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:176: error: Error: No resource found that matches the given name: attr 'android:subtitle'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:177: error: Error: …
Run Code Online (Sandbox Code Playgroud)

android android-library actionbarsherlock

13
推荐指数
2
解决办法
5149
查看次数

Android结算库错误

大家.
我刚开始在应用程序中购买应用程序.
这对我来说是新事物.
现在我在网上看到了一些例子,我发现在将结算库链接到它之前,github上的一个项目充满了错误.
当我这样做时,我刚解决了项目中的错误,但仍然有一个感叹号红色标记,因为android计费库包有错误.
我检查了错误,但我无法解决它,因为我不明白如何.
拜托,伙计们,我真的需要一些帮助.

我在这些行中得到了错误

    @Override 
    public android.os.IBinder asBinder()
    {
        return this;
    }
Run Code Online (Sandbox Code Playgroud)

在asBinder中的错误和它的说法"在这一行的多个标记

- The method asBinder() of type IMarketBillingService.Stub must override a superclass method  
- implements android.os.IInterface.asBinder"
Run Code Online (Sandbox Code Playgroud)

与此代码相同,我也收到错误

    @Override
    public android.os.Bundle sendBillingRequest(android.os.Bundle bundle) throws android.os.RemoteException     
    {
        android.os.Parcel _data = android.os.Parcel.obtain();
        android.os.Parcel _reply = android.os.Parcel.obtain();
        android.os.Bundle _result;
        try {
            _data.writeInterfaceToken(DESCRIPTOR);
            if ((bundle!=null)) {
                _data.writeInt(1);
                bundle.writeToParcel(_data, 0);
            } else {
                _data.writeInt(0);
            }
            mRemote.transact(Stub.TRANSACTION_sendBillingRequest, _data, _reply, 0);
            _reply.readException();
            if ((0!=_reply.readInt())) 
            {
                _result = android.os.Bundle.CREATOR.createFromParcel(_reply);
            } else {
                _result …
Run Code Online (Sandbox Code Playgroud)

android android-library android-billing

13
推荐指数
1
解决办法
1425
查看次数

在android中的依赖列表appcompat中找到2个版本的android-support-v4.jar

当我将appcompat项目添加为库时,我得到以下错误:

- found 2 versions of android-support-v4.jar in the dependency list appcompat in  android. 

- `aapt.exe` has stop working.
Run Code Online (Sandbox Code Playgroud)

怎么解决这个?

android android-appcompat android-library

13
推荐指数
2
解决办法
2万
查看次数

Android支持multidex库实现

我已达到魔法dex限制,因为我的应用程序使用了大量的jar(驱动器api,greendao,文本到pdf,支持..).

我目前的解决方案是,我真的创建了第二个apk,仅用于谷歌驱动器,我从主apk调用.但现在我发现android最终支持这个库.我的问题只是我不知道如何实现它(最好没有gradle).我找不到任何好的教程.

Okey我正在试图实现这个...我发现了这个:http: //blog.osom.info/2014/10/multi-dex-to-rescue-from-infamous-65536.html

我补充说:

 android:name="android.support.multidex.MultiDexApplication"
Run Code Online (Sandbox Code Playgroud)

到我的清单文件和

protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
}
Run Code Online (Sandbox Code Playgroud)

到我的mainactivity.java

还为eclipse安装了gradle插件,导出gradle以获取build.gradle文件,我改为:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':android-support-v7-appcompat')
    compile project(':Sync')
    compile project(':gdrive:google-play-services_lib')
}


android {
    compileSdkVersion 14
    buildToolsVersion "21.1.1"


    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src-gen','src']
            resources.srcDirs = ['src-gen','src']
            aidl.srcDirs = ['src-gen','src']
            renderscript.srcDirs = ['src-gen','src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build …
Run Code Online (Sandbox Code Playgroud)

android dex android-library android-gradle-plugin

13
推荐指数
2
解决办法
4万
查看次数

如何在另一个库中包含Android库模块?

我正在构建一个打包为aar并分发给第三方开发人员的Android库.

结构非常简单:

项目--- libraryA --- libraryB

libraryA需要libraryB,这就是为什么在它的gradle文件中有这个:

compile project(':libraryB')
Run Code Online (Sandbox Code Playgroud)

而settings.gradle有

include ':libraryB', ':libraryA'
Run Code Online (Sandbox Code Playgroud)

但是,如果我将项目构建为aar,它只包含libraryA.我错过了什么?

我阅读了对此的回答:Android Studio如何从多个库项目中打包单个AAR?

这还不可能吗?我认为将代码拆分成多个模块并不是一种不好的做法?

android gradle android-library android-gradle-plugin

13
推荐指数
2
解决办法
3180
查看次数

如何将自己的github分叉库导入android studio

我在GitHub上找到了一个很好的开放库,我使用Gradle依赖项将它导入到我的Android Studio项目中,但后来我意识到我需要对它进行一些修改.

所以我在我的GitHub上分叉了库,完成了修改并要求提取请求,但我不能等到他们批准并将我的修改与原始代码合并.

有没有办法使用依赖项将我的分叉库(在我的Github中)导入我的Android Studio项目,而不是原始库?

github gradle android-library android-studio android-gradle-plugin

13
推荐指数
2
解决办法
2864
查看次数

我的Android Studio中安装了哪个版本的支持库

我尝试CardView在我的应用程序中添加一个,所以我在gradle中添加了以下依赖项

compile 'com.android.support:cardview-v7:22.2.1'

我意识到错误是由于我给出了错误的版本号.在看了官方的谷歌文档后,我才知道它Android Support Repository用于存放appcompat库. 在此输入图像描述

正如您所看到的,我安装的支持存储库是版本33.但是如果我将我的gradle更改为版本33,它仍然显示错误.

如何查看android studio中我的AppCompatLibrary版本?

编辑:

build.gradle 文件

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 22
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.spintum.preexam"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    //    compile fileTree (dir:'libs',include:'achartengine-*.jar')
    //compile fileTree('libs/achartengine-1.1.0.jar')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:percent:22.2.0'
    compile 'com.android.support:design:22.2.1' …
Run Code Online (Sandbox Code Playgroud)

android android-library android-studio

13
推荐指数
2
解决办法
9864
查看次数

手机和平板电脑模块与Android库

我想创建一个单独的模块,以便我可以在项目之间共享它.该模块将有Android组件.因此,在创建新模块时,选项包括手机和平板电脑模块和Android库.我想知道两者之间有什么区别.谢谢

android android-library android-module

13
推荐指数
1
解决办法
2548
查看次数