File not found while trying to compile Telegram source code - java

I am trying to build an app like Telegram.I downloaded their source code (https://github.com/DrKLO/Telegram) (for Android).
My main problem is that,when I try to compile the code and export it to my mobile phone,using Android Studio I recive this error:
Error:A problem was found with the configuration of task ':TMessagesProj:packageDebug'.
File 'C:\Users\Bogdan\Desktop\Telegram\Telegram-master\TMessagesProj\config\debug.keystore' specified for property 'signingConfig.storeFile' does not exist.
Obviously a file is missing,but which,and how can I solve this problem?
Thank you!
P.S. Can you please provide me with a link to the source code of an app similar like this one,or similar to whatsapp?

Change Telegram/TMessagesProj/build.gradle and remove or comment signing option in gradle config, like this:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:22.2.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.5.+'
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
/**
signingConfigs {
debug {
storeFile file("config/debug.keystore")
}
release {
storeFile file("config/release.keystore")
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
*/
buildTypes {
debug {
debuggable true
jniDebuggable true
// signingConfig signingConfigs.debug
}
release {
debuggable false
jniDebuggable false
//signingConfig signingConfigs.release
}
foss {
debuggable false
jniDebuggable false
// signingConfig signingConfigs.release
}
}
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml'
}
sourceSets.foss {
manifest.srcFile 'config/foss/AndroidManifest.xml'
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 572
versionName "3.0.1"
}
}

Related

Implementing hide api for android 30 in project

I decompiled fmradio app for xiaomi. For using hidden api i copyd and replaced android.jar file from https://drive.google.com/drive/folders/185jgOthBI_qXzeS14s795LMGSekSTw5_. I have gradles:
#project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
#module
plugins {
id 'com.android.application'
}
android {
applicationVariants.all { variant ->
//variant.packageApplicationProvider.get().outputDirectory = new File(project.getRootDir().absolutePath + "/" + variant.buildType.name + "/")
variant.outputs.all { output ->
output.outputFileName = "FMRadio" + (variant.buildType.name.toLowerCase().contains("release") ? "" : "-" + variant.buildType.name) + ".apk"
}
}
signingConfigs {
release {
def f = file("../local.properties")
if (f.exists()) {
def props = new Properties()
f.withInputStream { props.load(it) }
storeFile file(props.RELEASE_KEY_PATH)
storePassword props.RELEASE_STORE_PASSWORD
keyAlias props.RELEASE_KEY_ALIAS
keyPassword props.RELEASE_KEY_PASSWORD
} else {
def writer = new FileWriter(f.path)
writer.write("RELEASE_KEY_PATH=\n")
writer.write("RELEASE_KEY_PASSWORD=\n")
writer.write("RELEASE_KEY_ALIAS=\n")
writer.write("RELEASE_STORE_PASSWORD=")
writer.close()
throw new IOException("File $f.name was created. please fill it by values of your release key.")
}
}
}
compileSdkVersion 30
buildToolsVersion "33.0.0"
defaultConfig {
applicationId 'com.miui.fmservice'
minSdkVersion 30
targetSdkVersion 31
versionCode 30
versionName "11"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.fragment:fragment:1.5.3'
}
But after trying to sync project with gradle files i get a large error stack trace,which you can find at https://pastebin.com/PfeN1viv. Help me please why this error happens. May be in android 30 i can't use hidden api? Thanks everybody for any help.

generateReleaseBuildConfig errors out in a library

Android Studio project. I have two library modules, neither of them has any Java in it. I'm trying to suppress BuildConfig generation, so that there's no generated Java either. The gradle file for the first one goes:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 3
targetSdkVersion 26
externalNativeBuild {
ndkBuild {
abiFilters "armeabi", "x86", "x86_64", "armeabi-v7a", "mips", "arm64-v8a"
targets "pad", "gif"
}
}
}
buildTypes {
release {
minifyEnabled false
}
debug {
jniDebuggable true
}
}
externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
}
}
}
dependencies {}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
For the other:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 3
targetSdkVersion 26
externalNativeBuild {
ndkBuild {
abiFilters "armeabi", "x86", "x86_64", "armeabi-v7a", "mips", "arm64-v8a"
}
}
}
buildTypes {
release {
minifyEnabled false
}
debug {
jniDebuggable true
}
}
externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
}
}
flavorDimensions 'Color'
productFlavors {
Blue {
dimension "Color"
externalNativeBuild {
ndkBuild {
cppFlags "-DBLUE"
}
}
}
Red {
dimension "Color"
externalNativeBuild {
ndkBuild {
cppFlags "-DRED"
}
}
}
}
}
dependencies {
implementation project(':Foo')
}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
The first one worked for a while, no problem. The second one, I've created just today, and the Gradle sync on that fails:
A problem occurred configuring project ':LibBar'.
Could not get unknown property 'generateReleaseBuildConfig' for project ':LibBar' of type org.gradle.api.Project.
If I comment that line out, it complains about generateDebugBuildConfig.
The second module depends on the first one, not sure if it matters.
Both have a manifest with nothing but package.
What am I missing? I've tried cleaning the project, invalidating the caches. Gradle is the latest, so is Android Studio (just updated).
The build system decorates the step name with the current build flavor. So it should be instead:
afterEvaluate {
generateBlueReleaseBuildConfig.enabled = false
generateBlueDebugBuildConfig.enabled = false
generateRedReleaseBuildConfig.enabled = false
generateRedDebugBuildConfig.enabled = false
}

Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.google.android.gms.security.ProviderInstaller

Hello Fellows when i was trying to add the admob SDK i got this error :
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.google.android.gms.security.ProviderInstaller
I've tried
Invalidating cache
cleaning and rebuilding
using ./gradlew build --stacktrace --info command
but without success.
This is what im getting every time :
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.google.android.gms.security.ProviderInstaller
Here are my app build.grable :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "ar.rulosoft.mimanganu"
versionCode 92
versionName "1.92"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 15
}
signingConfigs {
release {
storeFile file("../mimanganu.jks")
storePassword 'mimanganu'
keyAlias 'mimanganu'
keyPassword 'mimanganu'
}
debug {
storeFile file("../mimanganu.jks")
storePassword 'mimanganu'
keyAlias 'mimanganu'
keyPassword 'mimanganu'
}
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
disable 'NewApi' //Avoid problems in Android Studio 2.4 preview 6
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
signingConfig signingConfigs.debug
}
}
compileOptions.encoding = 'UTF-8'
flavorDimensions "builds"
productFlavors {
fdroid {
signingConfig signingConfigs.release
versionNameSuffix '-fdroid'
dimension "builds"
}
github {
signingConfig signingConfigs.release
//removed to maintain updates as now are
dimension "builds"
}
}
}
android.sourceSets {
test {
java.srcDirs += "$projectDir/src/testShare"
}
androidTest {
java.srcDirs += "$projectDir/src/testShare"
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:25.3.1'
}
dependencies {
final ANDROID_SUPPORT = '28.0.0'
implementation "com.android.support:support-v4:$ANDROID_SUPPORT"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:design:$ANDROID_SUPPORT"
implementation "com.android.support:appcompat-v7:$ANDROID_SUPPORT"
implementation "com.android.support:recyclerview-v7:$ANDROID_SUPPORT"
implementation "com.android.support:preference-v7:$ANDROID_SUPPORT"
api project(':imageviewtouchlibrary')
implementation 'rapid.decoder:library:0.3.0'
implementation 'rapid.decoder:jpeg-decoder:0.3.0'
implementation 'rapid.decoder:png-decoder:0.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0' //on 3.10.0 are deprecated some ciphers
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'com.squareup.duktape:duktape-android:1.3.0'/* v 1.2.0 need 4+mb extra*/
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
implementation 'com.evernote:android-job:1.2.5'
githubImplementation 'com.google.android.gms:play-services-base:16.0.1'
// ADDED BY O D I N
implementation 'com.google.android.gms:play-services-ads:17.1.1'
// ADDED BY O D I N
implementation 'ch.acra:acra:4.9.2'
fdroidApi project(':fakegps')
// for device-based testing
androidTestImplementation "com.android.support:support-annotations:$ANDROID_SUPPORT"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'junit:junit:4.12'
// for host-based testing
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.0-beta-1'
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
}
Project's build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
// ADDED BY O D I N
maven {
url "https://maven.google.com"
}
// ADDED BY O D I N
maven {
url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository'
}
google()
}
}
after so many attempt to add the SDK i still can't find any solution for this, Hope i find it here
Add maven { url 'https://maven.fabric.io/public' } to your Project build.gradle. Like below. This fixed it for me.
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
add
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Multidex support prior to Android 5.0
dependencies {
def multidex_version = "2.0.1"
implementation 'androidx.multidex:multidex:$multidex_version'
}
https://developer.android.com/studio/build/multidex
I've met the same kind of error : com.android.tools.r8.utils.AbortException: Error: Program type already present: [com.some.lib].
After dumping all the dependencies in console (via ./gradlew dependencies > ./dept.txt), I found out a new added aar does contain the same dependent library as reported above, so just exclude that out. It's done.
implementation ('the-new-library') {
transitive = true
exclude group : 'duplicate-lib-pkg', module:"duplicate-lib-name"
}

How to use .so files in Android

I am tring to add a C++ library into my Android project, but I keep getting the error:
Could not get unknown property 'jniLibs' for source set 'main' of type org.gradle.api.internal.tasks.DefaultSourceSet.
The project attempts to use a .so library of SQLite ( amalgamation).
How can I include the .so lib in my project and link it successfully to be able to call its functions?
Thank you all in advance.
My build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildToolsVersion '27.0.3'
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
remove config in build.gradle. This path is the default value of jniLibs, no customer config is needed.
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
or try with this config
sourceSets {
main {
jniLibs.srcDir(['src/main/jniLibs'])
}
}
copy the so file into app/src/main/jniLibs.
add the JNI java interface jar into your dependency.
System.LoadLibrary(libName) // for example you put xxx.so into jniLibs folder. here would be System.LoadLibrary("xxx")
Use the native method in JNI java class to call so method.

I have an error in my gradle:

I have an error in my gradle:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\El-Othmane\Desktop\tes11\android2\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\El-Othmane.gradle\caches\transforms-1\files-1.1\support-core-ui-26.1.0.aar\744d5e6087e939bc5d55ea9f4d6a237d\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager$2.class]))
enter code here Here is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
compile('com.google.android.gms:play-services:+') { exclude module: 'support-v4' }
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
First add this library in Gradle:
compile 'com.android.support:multidex:1.0.0'
Also you can add multidex:
multiDexEnabled true
and make your application to extend class MultiDexApplication.
Put code like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName "1.3"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
apply plugin: 'com.google.gms.google-services'
You are talking about how to exclude V4 See
Instead of V4 you can put V7 also like this
compile 'com.android.support:appcompat-v7:25.4.0'
You got this error may be because of Prograurd Duplicate zip entry
check below Links1 , Links2
Hope this solved your problem.
The error is expected because you're using an old support library which is conflicted with your compileSdkVersion and Google play service. So, you need to change your build.gradle to something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
// Don't use the following
//compile files('libs/support-v4-19.0.1.jar')
// instead, use support library with the same version with your compileSdkVersion
compile 'com.android.support:support-v4:27.1.1'
// You should NOT use all the google play service
// use what you need, please refer to https://developers.google.com/android/guides/setup
compile 'com.google.android.gms:play-services:11.2.0'
}

Categories

Resources