没有参数调用 public android.app.Service() 失败
Failed to invoke public android.app.Service() with no args
当我尝试从 API 获取数据时,改造响应仅在 service Array 有数据时失败是成功的并且有其他所有数据但是当 service Array 对失败方法进行数据改造时给出此消息:Failed to invoke public android.app.Service() with no args
第一次进行改造工作,卡在这里,累了请提前致谢
当服务数组有数据时JSON出现错误
{
id: 1,
profile_image: "post_images/1594969413profile.jpg",
firstname: "bilawal",
lastname: "jabbar",
address: "Sansfrasico",
blog: [
{
id: 1,
artist_profile_id: 1,
title: "dsd",
description: "sdsd",
photo: "http://ec2-54-161-107-128.compute-1.server.com/post_images/1594811497blog.jpg",
likes: 0,
created_at: "15/07/20",
like_link: "http://ec2-54-161-107-128.compute-1.server.com/api/like_blog/2",
artist_image: "http://ec2-54-161-10128.compute1.server.com/post_images/1594969413profile.jpg",
single_blog_link: "http://ec2-54-161-107-128.compute-1.server.com/api/blog/2"
}],
services: [
{
name: "test",
details: "asasasasas",
feature_image: "http://ec2-54-161-107-128.comp1.server.com/post_images/1594987588feature.jpg",
price: 2,
price_type: "Iix",
rating: "No Yet Rating"
}]
}
当服务数组在JSON中没有数据时工作顺利没有错误
{
id: 2,
profile_image: "no",
firstname: "Hamza",
lastname: "Dj Yo",
address: "no",
blog: [ ],
services: [ ]
}
服务Class
package com.example.djikon;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Service {
@SerializedName("name")
@Expose
private String name;
@SerializedName("details")
@Expose
private String details;
@SerializedName("feature_image")
@Expose
private String featureImage;
@SerializedName("price")
@Expose
private Integer price;
@SerializedName("price_type")
@Expose
private String priceType;
@SerializedName("rating")
@Expose
private String rating;
/**
* No args constructor for use in serialization
*
*/
public Service() {
}
public Service(String name, String details, String featureImage, Integer price, String priceType, String rating) {
super();
this.name = name;
this.details = details;
this.featureImage = featureImage;
this.price = price;
this.priceType = priceType;
this.rating = rating;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public String getFeatureImage() {
return featureImage;
}
public void setFeatureImage(String featureImage) {
this.featureImage = featureImage;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public String getPriceType() {
return priceType;
}
public void setPriceType(String priceType) {
this.priceType = priceType;
}
public String getRating() {
return rating;
}
public void setRating(String rating) {
this.rating = rating;
}
}
如果需要,还有主要对象 Class
package com.example.djikon;
import android.app.Service;
import java.util.List;
public class DJProfileModel {
private Integer id;
private String profile_image;
private String firstname;
private String lastname;
private String address;
private List<Blog_Model> blog;
private List<Service> services;
/**
* No args constructor for use in serialization
*
* @param body
*/
public DJProfileModel(DJProfileModel body) {
}
public DJProfileModel(Integer id, String profileImage, String firstname, String lastname, String address, List<Blog_Model> blog, List<Service> services) {
super();
this.id = id;
this.profile_image = profileImage;
this.firstname = firstname;
this.lastname = lastname;
this.address = address;
this.blog = blog;
this.services = services;
}
public Integer getId() {
return id;
}
public String getProfile_image() {
return profile_image;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getAddress() {
return address;
}
public List<Blog_Model> getBlog() {
return blog;
}
public List<Service> getServices() {
return services;
}
}
我在使用 'Here'JSONCONVERT 自动生成 class 时遇到了这个问题。为了解决这个问题,我为这个服务响应数组制作了自己的class。现在一切顺利。
这是我亲手制作的class:
package com.example.djikon;
public class model {
private String name,
details,
feature_image,
price_type,
rating;
private int price;
public model(String name, String details, String feature_image, int price, String price_type, String rating) {
this.name = name;
this.details = details;
this.feature_image = feature_image;
this.price = price;
this.price_type = price_type;
this.rating = rating;
}
public String getName() {
return name;
}
public String getDetails() {
return details;
}
public String getFeature_image() {
return feature_image;
}
public int getPrice() {
return price;
}
public String getPrice_type() {
return price_type;
}
public String getRating() {
return rating;
}
}
当我尝试从 API 获取数据时,改造响应仅在 service Array 有数据时失败是成功的并且有其他所有数据但是当 service Array 对失败方法进行数据改造时给出此消息:Failed to invoke public android.app.Service() with no args
第一次进行改造工作,卡在这里,累了请提前致谢
当服务数组有数据时JSON出现错误
{
id: 1,
profile_image: "post_images/1594969413profile.jpg",
firstname: "bilawal",
lastname: "jabbar",
address: "Sansfrasico",
blog: [
{
id: 1,
artist_profile_id: 1,
title: "dsd",
description: "sdsd",
photo: "http://ec2-54-161-107-128.compute-1.server.com/post_images/1594811497blog.jpg",
likes: 0,
created_at: "15/07/20",
like_link: "http://ec2-54-161-107-128.compute-1.server.com/api/like_blog/2",
artist_image: "http://ec2-54-161-10128.compute1.server.com/post_images/1594969413profile.jpg",
single_blog_link: "http://ec2-54-161-107-128.compute-1.server.com/api/blog/2"
}],
services: [
{
name: "test",
details: "asasasasas",
feature_image: "http://ec2-54-161-107-128.comp1.server.com/post_images/1594987588feature.jpg",
price: 2,
price_type: "Iix",
rating: "No Yet Rating"
}]
}
当服务数组在JSON中没有数据时工作顺利没有错误
{
id: 2,
profile_image: "no",
firstname: "Hamza",
lastname: "Dj Yo",
address: "no",
blog: [ ],
services: [ ]
}
服务Class
package com.example.djikon;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Service {
@SerializedName("name")
@Expose
private String name;
@SerializedName("details")
@Expose
private String details;
@SerializedName("feature_image")
@Expose
private String featureImage;
@SerializedName("price")
@Expose
private Integer price;
@SerializedName("price_type")
@Expose
private String priceType;
@SerializedName("rating")
@Expose
private String rating;
/**
* No args constructor for use in serialization
*
*/
public Service() {
}
public Service(String name, String details, String featureImage, Integer price, String priceType, String rating) {
super();
this.name = name;
this.details = details;
this.featureImage = featureImage;
this.price = price;
this.priceType = priceType;
this.rating = rating;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public String getFeatureImage() {
return featureImage;
}
public void setFeatureImage(String featureImage) {
this.featureImage = featureImage;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public String getPriceType() {
return priceType;
}
public void setPriceType(String priceType) {
this.priceType = priceType;
}
public String getRating() {
return rating;
}
public void setRating(String rating) {
this.rating = rating;
}
}
如果需要,还有主要对象 Class
package com.example.djikon;
import android.app.Service;
import java.util.List;
public class DJProfileModel {
private Integer id;
private String profile_image;
private String firstname;
private String lastname;
private String address;
private List<Blog_Model> blog;
private List<Service> services;
/**
* No args constructor for use in serialization
*
* @param body
*/
public DJProfileModel(DJProfileModel body) {
}
public DJProfileModel(Integer id, String profileImage, String firstname, String lastname, String address, List<Blog_Model> blog, List<Service> services) {
super();
this.id = id;
this.profile_image = profileImage;
this.firstname = firstname;
this.lastname = lastname;
this.address = address;
this.blog = blog;
this.services = services;
}
public Integer getId() {
return id;
}
public String getProfile_image() {
return profile_image;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getAddress() {
return address;
}
public List<Blog_Model> getBlog() {
return blog;
}
public List<Service> getServices() {
return services;
}
}
我在使用 'Here'JSONCONVERT 自动生成 class 时遇到了这个问题。为了解决这个问题,我为这个服务响应数组制作了自己的class。现在一切顺利。
这是我亲手制作的class:
package com.example.djikon;
public class model {
private String name,
details,
feature_image,
price_type,
rating;
private int price;
public model(String name, String details, String feature_image, int price, String price_type, String rating) {
this.name = name;
this.details = details;
this.feature_image = feature_image;
this.price = price;
this.price_type = price_type;
this.rating = rating;
}
public String getName() {
return name;
}
public String getDetails() {
return details;
}
public String getFeature_image() {
return feature_image;
}
public int getPrice() {
return price;
}
public String getPrice_type() {
return price_type;
}
public String getRating() {
return rating;
}
}