Rally Rest Api-Android 应用程序-即使在导入所需的 jars 后也找不到 class

Rally Rest Api-Android app-Getting No class found even after importing required jars

我正在尝试建立集会 Android app.I 已尝试 https://github.com/RallyTools/RallyRestToolkitForJava 鉴于我已经添加了罐子。 1.commons-codec-1.6.jar 2.gson-2.2.4.jar 3.httpclient-4.2.5.jar 4.org.apache.commons.logging-1.1.1.jar 5.httpcore-4.2.4.jar

我的mainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.response.QueryResponse;

import org.apache.http.HttpHost;
import org.apache.http.client.utils.URIUtils;



    public class MainActivity extends AppCompatActivity
{
    String host = "https://rally1.rallydev.com";
String applicationName = "Android-Rally";
RallyRestApi restApi;
Button buttonlogin;
EditText etemail,etpass;
QueryRequest qtestset;
QueryResponse response;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    etemail=(EditText) findViewById(R.id.etemail);
    etpass=(EditText) findViewById(R.id.etpassword);
    buttonlogin=(Button) findViewById(R.id.btnlogin);
    buttonlogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v)
        {
            if(etemail.equals("") && etpass.equals(""))
            {
                Toast.makeText(getApplicationContext(),"Enter your Rally Credentials",Toast.LENGTH_LONG).show();
            }
            else
            {
                try
                {
                    getRally();
                }
                catch (URISyntaxException e)
                {
                    e.printStackTrace();
                }
                qtestset = new QueryRequest("Defects");
                qtestset.setLimit(1);
                try
                {
                    response = restApi.query(qtestset);
                    if(!response.wasSuccessful())
                    {
                        Toast.makeText(getApplicationContext(),"Login Un-Successful",Toast.LENGTH_LONG).show();


                    }
                    else{
                        Toast.makeText(getApplicationContext(),"Login Successful",Toast.LENGTH_LONG).show();
                    }
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }



            }


        }
    });

}

public RallyRestApi getRally() throws URISyntaxException {
    String password = etemail.getText().toString();
    String email=etpass.getText().toString();
    restApi = new RallyRestApi(new URI(host), email,password);
    restApi.setApplicationName(applicationName);
    return restApi;
}
}

我的错误日志

04-18 14:07:16.299 11364-11364/com.example.apetkar.rally_poc D/AndroidRuntime: Shutting down VM 04-18 14:07:16.299 11364-11364/com.example.apetkar.rally_poc E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.apetkar.rally_poc, PID: 11364 java.lang.NoSuchMethodError: No static method extractHost(Ljava/net/URI;)Lorg/apache/http/HttpHost; in class Lorg/apache/http/client/utils/URIUtils; or its super classes (declaration of 'org.apache.http.client.utils.URIUtils' appears in /system/framework/org.apache.http.legacy.boot.jar) at org.apache.http.impl.client.DecompressingHttpClient.getHttpHost(DecompressingHttpClient.java:113) at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:108) at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:157) at com.rallydev.rest.client.HttpClient.doRequest(HttpClient.java:145) at com.rallydev.rest.client.BasicAuthClient.doRequest(BasicAuthClient.java:56) at com.rallydev.rest.client.HttpClient.doGet(HttpClient.java:221) at com.rallydev.rest.RallyRestApi.query(RallyRestApi.java:172) at com.example.apetkar.rally_poc.MainActivity.onClick(MainActivity.java:64) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

任何人都可以在这里提供帮助..现在坚持了几天..谢谢

android 运行 java 有什么特别的手机版吗?似乎 4.2 http 组件可能不兼容。我没有机会深入研究它,但我想知道是否有一组更新的组件与 android 环境兼容?您可以尝试分叉 RallyRestToolkitForJava 存储库并在本地更新依赖项以查看是否可以将其添加到 运行...

与包含的 Apache HTTP jar 和本机 Android 使用的 jar 存在 class 冲突。我通过分叉 Rally 项目并用 OKHttp 替换 Apache HTTP 来消除冲突来解决这个问题。我的更改在 github 中的分支中:https://github.com/rawslaw/RallyRestToolkitForJava