eclipse 将谷歌分析添加到 Android 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7895038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding google analytics to an android app
提问by nicktook
I have a working android app and now want to add google analytics to it. I am following the instructions here:
我有一个可用的 android 应用程序,现在想向它添加谷歌分析。我正在按照此处的说明操作:
http://code.google.com/mobile/analytics/docs/android/
http://code.google.com/mobile/analytics/docs/android/
When I add the import statement:
当我添加导入语句时:
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
I get the error:
我收到错误:
The import com.google.android cannot be resolved
I have created a libs directory in the project and placed the libGoogleAnalytics.jar file in it. I tried adding this to the AndroidManifest.xml:
我在项目中创建了一个 libs 目录,并将 libGoogleAnalytics.jar 文件放在其中。我尝试将其添加到 AndroidManifest.xml 中:
<uses-library android:name="com.google.android.analytics" />
I have tried opening and closing Eclipse and doing 'Project / Clean'. Nothing seems to affect the problem. I am somewhat new to Java. What am I missing?
我尝试打开和关闭 Eclipse 并执行“项目/清理”。似乎没有什么会影响问题。我对 Java 有点陌生。我错过了什么?
回答by Iulia Barbu
I think you should add library libGoogleAnalytics.jar to build path (in libs right click on libGoogleAnalytics.jar -> BuildPAth -> Add to Build Path) Do not add anything in Manifest file and in your java file use cmd+Shift+O(for Mac, for Windows Ctrl+Shift+O) to automatically organize your imports)
我认为您应该将库 libGoogleAnalytics.jar 添加到构建路径(在 libs 中右键单击 libGoogleAnalytics.jar -> BuildPAth -> 添加到构建路径)不要在 Manifest 文件中添加任何内容,在您的 java 文件中使用 cmd+Shift+O(对于 Mac,对于 Windows Ctrl+Shift+O) 以自动组织您的导入)