因为公司需要做个社交+视频+动态类型的app.
找了好多方案,于是决定使用国内IM SDK
外加炫丽的UI
皮肤,
IM
不在讨论范围而UI
当即使用Telegram吊得炸天的app
Telegram for Android
Telegram是一款关注速度和安全性的即时通讯应用。它超快,简单,免费。这个github包含了Android Telegram应用的官方源代码。
说明:部分网址需要科学上网
Telegram Download from github
进入Telegram进行下载:
- 使用
Android Studio
的git功能, URL:https://github.com/DrKLO/Telegram.git
- 打开命令行进入项目根目录,运行:
git submodule update --init --recursive
自动依赖缺少的文件
或者
- 下载Download ZIP并解压
- 打开命令行进入项目根目录
- 运行:
git init
命令初始化 - 运行:
git submodule update --init --recursive
自动依赖缺少的文件
备注
1.第二种方式下载github会比较快
NDK报错信息原因
默认下载的工程jni/libtgvoip
目录为空,Gradle无法编译成功
处理方案
当使用git clone下来的工程中带有submodule时,初始的时候,submodule的内容并不会自动下载下来的,此时,只需执行如下命令:
git submodule update --init --recursive
下载google-services.json
- 请到这个google网址下载
- 把下载的
google-services.json
放到指定目录工程根目录/TMessagesProj/
下 - 获取apk签名文件SHA-1.如果使用debug模式命令:
uinx/linux
keytool -exportcert -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
windows
keytool -exportcert -list -v \ -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
debug keystore默认密码:android
具体可以查看官方手册
注意:
google-services.json
注册时使用的package_nameDebug
模式下为
org.telegram.messenger.beta
关于values错误信息参考
编译时对于values出错了,如果你也遇到以下类似错误日志:
AGPBI: {"kind":"error","text":"Multiple substitutions specified in non-positional format; did you mean to add the formatted\u003d\"false\" attribute?","sources":[{"file":"/Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/src/main/res/values-ko/strings.xml","position":{"startLine":1604,"startColumn":4,"startOffset":93930,"endColumn":86,"endOffset":94012}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Unexpected end tag string","sources":[{"file":"/Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/src/main/res/values-ko/strings.xml","position":{"startLine":1604,"startColumn":4,"startOffset":93930,"endColumn":86,"endOffset":94012}}],"original":"","tool":"AAPT"}
/Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/merged/armv7/debug/values-ko/values-ko.xml:232: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
/Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/merged/armv7/debug/values-ko/values-ko.xml:232: error: Unexpected end tag string
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /Users/yuhang/Android/Tools/android-sdk-macosx/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /Users/yuhang/Android/Tools/android-sdk-macosx/platforms/android-26/android.jar -M /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/manifests/full/armv7/debug/AndroidManifest.xml -S /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/merged/armv7/debug -m -J /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/generated/source/r/armv7/debug -F /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/armv7/debug/resources-armv7Debug.ap_ --custom-package org.telegram.messenger -0 apk --preferred-density xxhdpi --output-text-symbols /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/symbols/armv7/debug --no-version-vectors}
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
... 41 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing process /Users/yuhang/Android/Tools/android-sdk-macosx/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /Users/yuhang/Android/Tools/android-sdk-macosx/platforms/android-26/android.jar -M /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/manifests/full/armv7/debug/AndroidManifest.xml -S /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/merged/armv7/debug -m -J /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/generated/source/r/armv7/debug -F /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/res/armv7/debug/resources-armv7Debug.ap_ --custom-package org.telegram.messenger -0 apk --preferred-density xxhdpi --output-text-symbols /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/build/intermediates/symbols/armv7/debug --no-version-vectors}
at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1237)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:911)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:822)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:664)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:48)
at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:58)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/yuhang/Android/Tools/android-sdk-macosx/build-tools/26.0.2/aapt'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:380)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
... 9 more
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':TMessagesProj:processArmv7DebugResources'.
> Failed to execute aapt
原因
res/merged/armv7/debug/values-ko/values-ko.xml:232
路径下Strings.xml错误.
处理
报错字符串:
修改为:
关于release.keystore签名文件报错参考
编译时签名文件找不到,下列是错误日志:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':TMessagesProj:validateSigningArmv7Debug'.
> Keystore file /Users/yuhang/Dropbox/Android/Great-Dao/Project/Telegram/TMessagesProj/config/release.keystore not found for signing config 'debug'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
原因
编译时TMessagesProj/config
目录下找不到release.keystore
文件
处理
创建一个新的keystore签名文件并且把文件放入TMessagesProj/config
目录下
- storePassword:
password
- keyAlias:
alias
- keyPassword:
password
也可以去csdn上下载,现在方便起见还先这上面当cdn了,下次等所有功能都可以跑起来就放github上.现在就先将就看一下好了,csdn最少是2分起.
关于Application Installation Failed安装失败
运行时Rebuild Project没有报错但安装时提示安装失败,试图重新定义权限
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION: Package org.telegram.messenger.beta attempting to redeclare permission org.telegram.messenger.permission.C2D_MESSAGE already owned by org.telegram.messenger]
原因
安装会检查AndroidManifest.xml
文件权限的合法性,结果发现下列权限无效
处理
把AndroidManifest.xml
文件中
修改为:
备注
把org.telegram.messenger
原来的packagename修改为新的就行.
我当前是DEBUG
模式.因此packagename为org.telegram.messenger.beta
如果有需求可以把config
目录下对应的环境,修改成对应的权限.我目前只用到DEBUG
模式
Caused by: java.lang.IllegalArgumentException: App ID length must be 32 characters. 异常信息
运行App发现报错:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.telegram.messenger.beta, PID: 9554
java.lang.RuntimeException: Unable to resume activity {org.telegram.messenger.beta/org.telegram.ui.LaunchActivity}: java.lang.IllegalArgumentException: App ID length must be 32 characters.
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3519)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3559)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2807)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6381)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
Caused by: java.lang.IllegalArgumentException: App ID length must be 32 characters.
at net.hockeyapp.android.utils.Util.sanitizeAppIdentifier(Util.java:134)
at net.hockeyapp.android.CrashManager.initialize(CrashManager.java:490)
at net.hockeyapp.android.CrashManager.register(CrashManager.java:124)
at net.hockeyapp.android.CrashManager.register(CrashManager.java:110)
at org.telegram.messenger.AndroidUtilities.checkForCrashes(AndroidUtilities.java:1320)
at org.telegram.ui.LaunchActivity.onResume(LaunchActivity.java:2033)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
at android.app.Activity.performResume(Activity.java:6974)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3496)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3559)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2807)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6381)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
原因
缺少参数HOCKEY_APP_HASH
处理
把文件org.telegram.messenger.BuildVars
里面的参数HOCKEY_APP_HASH
和HOCKEY_APP_HASH_DEBUG
都加上,同一个值就行.需要注册并登陆可以去这里
取页面里面的HOCKEYAPP_APP_ID
参数
备注:如果只需要App包起来,
BuildVars
必填参数
APP_HASH
:这里
APP_HASH
: 这里
HOCKEY_APP_HASH
:这里
HOCKEY_APP_HASH_DEBUG
:这里