首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Android中使用第三方jar文件

如何在Android中使用第三方jar文件
EN

Stack Overflow用户
提问于 2013-01-08 15:45:47
回答 1查看 845关注 0票数 0

我知道这个问题以前问过,但任何答案都对我有帮助。

我想使用SVG,但是Android看不到SVG jar。我添加了构建路径。并将库资源附加为libs文件夹。还在Android Manifest中添加了标签。但它并没有起作用。

问候

以下是我的Android宣言:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.svgexample2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.example.svgexample2.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>          
        </activity>
         <uses-library android:name="svg-android" android:required="true" />
    </application>

</manifest>

我的主要活动是:

代码语言:javascript
复制
package com.example.svgexample2;

import com.larvalabs.svgandroid.SVG;
import com.larvalabs.svgandroid.SVGParser;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class MainActivity extends Activity {

        RelativeLayout mainLayout;
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        ImageView myImg;
        SVG svgFile;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            mainLayout = new RelativeLayout(this);
            myImg = new ImageView(this);

            myImg.setBackgroundColor(Color.WHITE);

            SVG svgFile = SVGParser.getSVGFromResource(getResources(), R.drawable.image);
            myImg.setImageDrawable(svgFile.createPictureDrawable());

            mainLayout.addView(myImg);
            setContentView(mainLayout);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

下面是我的附加svgandroid.xml文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8">
<permissions>
<libraryname="svg-android" file="/home/breed/dev/Android/androidWorkspace/SvgExample2/libs/"/>
</permissions>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-08 15:48:12

AFAIK没有必要在您的清单中放置一个uses-librarysvgandroid.xml也应该是无用的。只需将.jar文件放在Android Eclipse Project的libs文件夹中即可。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14210374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档