gpt4 book ai didi

java - 导入 android.support.v4 包时遇到问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:50:49 25 4
gpt4 key购买 nike

我正在尝试将 android-support-v4.jar 包含到我的命令行 android 项目中。我的导入语句很简单:

import android.support.v4.NavUtils;

我已经将 jar 从 $ANDROID_HOME/extras/android/support/v4/android-support-v4.jar 复制到我项目的 libs/ 文件夹中,但是我使用 ant 构建时仍然收到以下错误:

package android.support.v4 does not exist

我的理解是,libs/ 文件夹中的任何 jar 都会自动包含在项目类路径中。

根据要求,ls -l 在根项目文件夹中的输出是

-rw-r--r--   1 Nick  staff  1192  4 Jan 15:08 AndroidManifest.xml
-rw-r--r-- 1 Nick staff 696 4 Jan 12:12 ant.properties
drwxr-xr-x 17 Nick staff 578 4 Jan 15:10 bin
-rw-r--r-- 1 Nick staff 3922 3 Jan 14:08 build.xml
drwxr-xr-x 4 Nick staff 136 3 Jan 15:11 gen
drwxr-xr-x 3 Nick staff 102 4 Jan 15:18 libs
-rw-r--r-- 1 Nick staff 441 3 Jan 14:08 local.properties
-rw-r--r-- 1 Nick staff 781 3 Jan 14:08 proguard-project.txt
-rw-r--r-- 1 Nick staff 563 3 Jan 14:08 project.properties
drwxr-xr-x 8 Nick staff 272 3 Jan 14:08 res
drwxr-xr-x 3 Nick staff 102 3 Jan 14:08 src

ant debug 的整个输出是

    Buildfile: /Users/Nick/DEVELOPMENT/PROJECTS/MyFirstApp/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
[checkenv] Android SDK Tools Revision 21.0.1
[checkenv] Installed at /Users/Nick/Development/SDKS/android-sdk-macosx

-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-build-setup:
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.2
[gettarget] API level: 17
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency] No Libraries
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on

-pre-build:

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
[echo] ----------
[echo] Handling Resources...
[aapt] No changed resources. R.java and Manifest.java untouched.
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:
[javac] Compiling 1 source file to /Users/Nick/DEVELOPMENT/PROJECTS/MyFirstApp/bin/classes
[javac] /Users/Nick/DEVELOPMENT/PROJECTS/MyFirstApp/src/com/example/myfirstapp/DisplayMessageActivity.java:9: package android.support.v4 does not exist
[javac] import android.support.v4.NavUtils;
[javac] ^
[javac] /Users/Nick/DEVELOPMENT/PROJECTS/MyFirstApp/src/com/example/myfirstapp/DisplayMessageActivity.java:36: cannot find symbol
[javac] symbol : variable NavUtils
[javac] location: class com.example.myfirstapp.DisplayMessageActivity
[javac] NavUtils.navigateUpFromSameTask(this);
[javac] ^
[javac] 2 errors

最佳答案

您的导入语句不正确,应该是:

import  android.support.v4.app.NavUtils;

关于java - 导入 android.support.v4 包时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14164602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com